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

Too many tools

show
We don't always need a new t...
Mar 6 · General Musings with Kev...
13:53
Spotify Logo
 

This week I talk about the challenges of content planning and scheduling, and my preference for simple tools like pen-and-paper calendars over an excess of apps.

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, If you only have 10 or so minutes of free time for this email, instead of reading it, I’m going to ask that you either read this article or watch this video by Salma Alam-Naylor, where she explores her current thoughts on the tech industry and the impact AI is having on it. I’ve had a lot of thoughts on the current state of things circling around my head without being able to wrangle them in any coherent way, which she...

View this email in your browser (or share it with a friend!) Hello Reader, On Saturday morning, I passed 1 million subscribers on YouTube. I created my channel over 9 years ago. Around 5 months in, I hit 100 subscribers, and at the time, I was blown away that so many people liked my videos enough to bother subscribing. Three years later, I'd passed 100,000 subscribers, which I honestly didn't think was possible for a channel dedicated to vanilla HTML & CSS. And now it's one million. For a...

View this email in your browser (or share it with a friend!) Hello Reader, This week, I’m formatting things a little differently because the comments on a YouTube video I posted got me a little riled up 😅. So, starting with that video, I took a look at Temani Afif’s mind-blowing CSS-only graph theory CodePen. And while most people were pretty blown away by this as well, there were a fair number of comments about how this is breaking the separation of concerns and how CSS shouldn’t be able to...