Thoughts on CSS in 2024

Published on July 15, 2024 (ā†» July 29, 2024), filed under (RSS feed for allĀ categories).

I havenā€™t written about CSS in a while šŸ˜¬ (Instead, a new book about HTML optimization, some comments about veganism, and other random things.) Am I still alive? Yes! šŸ‘‹ (You can feel my heartbeat over at Frontend Dogma!)

So what are these thoughts, about CSS, in 2024? Let me keep it light and casual.

What I Appreciate

There are a few things I appreciate. These things arenā€™t necessarily what everyone else may be hyped up aboutā€”though they donā€™t exactly go unnoticed, either.

What I appreciate deeply, given how long and how much Iā€™ve missed that power, are all 86 * of todayā€™s selectors. (Iā€™ve explained a little in CSS: :has() and the Lost Paradigm.)

If you had me pick three selectors I particularly appreciate, Iā€™d choose :has(), :not(), and is:() (over :where(), because I usually like the added specificity).

Sure, there are other things I appreciate, like grid or container queries, but the reason why Iā€™m so selector-focused is that selectors have a direct impact on HTML code qualityā€  Whatā€™s in a style sheet is far less important than how the HTML looks likeā€”with separation of concerns, we can swap that out in an instant. (You know all of this, but this is such a misunderstood biggie, I have to hold myself back here!)

Favorites

I have some favorites, too.

Iā€™ve found myself to set scroll-behavior: smooth in most every new project. (It made quite a difference on the Worldā€™s Highest/Longest Website!)

I really like text-wrap: pretty, which had me dial down on the hyphens property and which obsoleted both tooling and habits around fine-tuning typography by setting no-break spaces.

Itā€™s old, but I also like ::selection, which shouldā€”couldā€”probably be used by more websites and apps.

There are a few things Iā€™m monitoring, like ::target-text, but thatā€™s not there yet.

That list may seem short, but thereā€™s surely a reason for this: Other ā€œbread and butterā€ properties and declarations are even older, and donā€™t feel like favorites because of their ubiquity. Yet others are so individual, i.e., project-specific, that I couldnā€™t call them favorites, either.

What I Donā€™t Need

Thereā€™s a lot that I donā€™t need from contemporary CSS.

Though not a ā€œfeatureā€ of CSS, I donā€™t use resets, and never have. As Iā€™ve written about resets in the past, I wonā€™t do so now. One angle that I havenā€™t played in the past, however, is to ask how we could have any projects without resets (which exist), if resets are so critical. I donā€™t think this point has ever been appreciated by reset proponents.

I donā€™t use logical properties (except for axis shorthands, like margin-block). Iā€™ve written about logical properties, too. Having worked on bi-directional projects, I know about their value (if I worked on any such project now, Iā€™d absolutely use logical properties)ā€”but experience working on international sites is what makes me be clear about when theyā€™re not needed. (Thereā€™s more here, sure, but this point of need also lacks appreciation.)

I use custom properties, but rarely. Theyā€™ve proven their value, but that value is limited when keeping style sheets DRY. Using declarations just once works. I know the field rushed past this, but boy, it does this all the time (hi Conditional Comments, AMP, and yes, resets).

There are more things I donā€™t need and use, but well, thatā€™s the beauty of web developmentā€”we donā€™t have to use it all. (Itā€™s good to keep an eye on whatā€™s becoming available though.)

ā§ This must be a somewhat strange look at CSS, in 2024. And yet, covering CSS pretty much all the time, I know this also adds perspective. Selectors could use more recognition. Favorites differ wildly. And we usually seem to write about what we need and want, not what we donā€™t need and want. (If you are explicit about your not-needs, email me so that I feature your perspective on Frontend Dogma!)

* Thatā€™s the number I have in my upcoming book, to learn-by-memorizing (yes!) HTML and CSS!

ā€  This needs explanation insofar as the range of impact goes from dictating HTML attributes (like classes), values (like class names), and even structure (like styling-related containers) to not affecting the HTML markup at all. Quality-wise, this then maps to potentially highly negatively impacting HTML quality (increased payload, decreased maintainability) to not impacting it at all (the highest level).

Was this useful or interesting? Share (toot) this post, and support my work by learning with myĀ ebooks!

About Me

Jens Oliver Meiert, on November 9, 2024.

Iā€™m Jens (long: Jens Oliver Meiert), and Iā€™m a frontend engineering leader and tech author/publisher. Iā€™ve worked as a technical lead for companies like Google and as an engineering manager for companies like Miro, Iā€™m a contributor to several web standards, and I write and review books for Oā€™Reilly and FrontendĀ Dogma.

I love trying things, not only in web development (and engineering management), but also in other areas like philosophy. Here on meiert.com I share some of my experiences and views. (Please be critical, interpret charitably, and giveĀ feedback.)