The way I write CSS is about to change again


View this email in your browser (or share it with a friend!)

PRE-S: Sending this week’s newsletter out early this week, which I’ll talk about more of why a little further down.


Hello Reader,

I’m so curious about how some of the new CSS features that are coming out now are going to impact how we author our stylesheets in the years to come.

I think the one that might have the biggest singular impact might be the advanced attr() function, which finally allows us to use the values of data attributes anywhere in our CSS.

Beyond that though, we’re getting:

  • mixins
  • functions
  • if statements
  • probably more than I’m forgetting!

At first, these types of things will be used similarly to how we use the same features in pre-processors like Sass, but over time, I can only guess that we will push on from there.

I’m thinking about this because I was thinking back on how I used to use custom properties, and how it's evolved over the years.

Custom properties are essentially variables, and we’ve had them in preprocessors for a long time.

When I first started using them, I treated them in essentially the same way.

Eventually, I realized that locally scoped custom properties were amazing (they’re not as great with pre-processors because of the limitations they have being pre-rendered).

Using locally scoped custom properties changed a lot of how I used them, and I started using many local properties that I could override where needed.

And most recently, I’ve shifted to using a lot of fallback values, like var(--card-font-size, --base-font-size).

This sets the default as the base font size, but it's super easy to overwrite it with a modifier or somewhere specific.

If you'd like to see this approach in action, you can see me go all-out in my Bento Grid video from a few weeks ago.

This evolution of how I’ve been using them has taken years.

I realize others go there before I did, but it’s still one of those things where, unless we have a specific need, there is often no reason to change how we work, so we just keep on doing what we know.

Then, we either see someone else do something new or think of a clever idea and test it out, and slowly but surely, we make some progress in how we might use something.

And with so many new features about to be added to CSS, it’ll be fun to see where things go in the short-term, but also how different things might look after they’ve been stable for a little while as well, and the new patterns and workflows that come from them.

Also, if you'd like to see custom functions and mixins in action, I haven't had a chance to play with them yet, but Dmitry Mayorov has a video looking at each:

One thing I will say is that I know a lot of people worry that this explosion of new features will make CSS more complicated.

In a way, it does, but the nice thing is, they don't change the learning curve.

The basics are still the basics.

There are no breaking changes and new complexities for beginners.

f anything a lot of things are easier for beginners now that we have the correct tools for the jobs we need to do instead of relying on hacks.

There is more to learn, but if you have a strong foundation in the language, adding on top of that foundational knowledge usually isn't too bad 😊.


Speaking of keeping up with modern CSS, the reason why this week’s newsletter is going out a few days earlier is that I want to let you know that Miriam Suzanne is hosting a workshop on CSS Layouts.

The workshop is on building more resilient and maintainable web layouts using modern CSS, covering all the essentials, from block and flexbox to grid, subgrid, container queries, box alignment, and more.

The reason I’m sending this out today instead of Sunday is because there is a $100 early-bird discount running through April 12, and I didn’t want anyone to miss out on it.

This isn’t a sponsored slot or anything, but I know a lot of my audience could benefit from it.

I always love learning from Miriam because she knows CSS layouts at a super deep level (and has even helped write the spec for container queries), but is also able to explain everything in a way we can all understand.

If you’re interested, you can watch a little preview, or get more information and register for the workshop here.

🙋‍♂️ What I’ve been up to this week

How to set a max-column count using Grid auto-fit or auto-fill

video preview

Both auto-fit and auto-fill are amazing, but sometimes they keep making more columns when you don’t want it to keep making more.

Setting a max-width on the grid can work, but I don’t always want to limit that to be too narrow either, so I found a way to set a maximum number of columns!

It does take a little bit of work, but once we have the custom properties set up, it works well and is easy to modify as well.

Here’s the CodePen from the video if you want to poke around with the code.

⚡ Quick tips of the week

🎙️ Podcast

Staying sane when things get busy

show
Staying sane when things get...
May 15 · General Musings with Kev...
16:24
Spotify Logo
 

I recently went through a period that could have led to burnout, but I managed to avoid it, so I thought I'd share how I managed to get through it.

LISTEN ON: APPLE | SPOTIFY | YOUTUBE | RSS

🔗 Other awesome stuff around from the web

🏁

Have a fantastic week!
Kevin


Are you looking to step up your CSS? I've got both free and premium courses to help with that! They cover a range of skill levels too 👇

Beginner friendly (and free)

HTML & CSS for Absolute Beginners

A free course that starts with the absolute basics, and gets to creating some layouts with Flexbox and Grid.

Enroll →

Intermediate

CSS Demystified

For those who've been writing CSS for a little bit now, but want to step up their game and start writing CSS with confidence!

Enroll →

Intermediate (Frontend Masters)

Build a Modern Site from Scratch

Build a fully responsive site using modern CSS features, along with some polished animations.

Enroll → (25% off first month of Frontend Masters if you use this affiliate link)

If you no longer want to get any emails from me, you can unsubscribe or you can edit your preferences if you'd like pick which emails you get from me.
600 1st Ave, Ste 330 PMB 92768, Seattle, WA 98104-2246

Hi! I'm Kevin

Weekly newsletter, where I talk about tangentially-related front-end development topics and share what I've been up to in the last week, plus any cool/fun/interesting/useful links I come across as well.

Read more from Hi! I'm Kevin

View this email in your browser (or share it with a friend!) Hello Reader, In the last three days, I’ve created more content than I usually do in one week (and no, don’t worry, I’m not about to try and sell you some productivity system 😆). As I sat down to write this, I wondered what I had done differently to get so much done, and at least some of it was due to a small tweak I made to my workflow on Monday. I won’t bore you with the details, but I want to talk about the idea of removing...

Selfie, standing in front of a canal in Amsterdam

View this email in your browser (or share it with a friend!) Hello Reader, And I’m back from Smashing Conf Amsterdam, where I had an absolutely wonderful time! Amsterdam is such a beautiful city Amsterdam is one of my favourite cities to visit, and Smashing knows how to put on a wonderful conference, so I had high expectations in combining the two, and it didn't disappoint 😊. As for my talk, it went great… and what an amazing venue to speak at! The Pathé Tuschinski theatre As for my talk, the...

View this email in your browser (or share it with a friend!) Hello Reader, I’m writing this from the airport, a few hours into a nine-hour layover. When I booked the flight, I knew this would be a long one, but I have a pile of work to get through, so it’s been a surprisingly productive Saturday. I normally try to avoid working on weekends, but over the last two months, it’s been more the norm than the exception. The launch of CSS Demystified, which just wrapped up, followed by my talk and...