A presentation at CSS Day in in Amsterdam, Netherlands by Sarah Dayan
Utility First CSS Isn’t Inline Styles Sarah Dayan | Principal Engineer at Algolia | CSS Day 2024
CSS Hi, I’m Sarah! 👋 Principal Engineer at Algolia JavaScript & CSS Lover Massive Cheese Enthusiast
“ Is CSS even a programming language?
“ Are you sure you don’t want to be a manager?
Atomic CSS Semantic CSS
Atomic CSS Semantic CSS
“ It violates separation of concerns!
“ It bloats the HTML!
“ It’s ugly and hard to read!
youtu.be/R50q4NES6Iw
“ It’s just the same as inline styles!
“ It’s just the same as inline styles!
Inline styles only have a local impact.
Well, almost 😅
No pseudo-classes No pseudo-elements No combinators No media queries No animations
Atomic classes live in style sheets.
.on-hover:text-red:hover { color: red; }
.group:hover .group-hover:text-red { color: red; }
Wait, it gets quirkier.
.peer:in-range ~ .peer-invalid { visibility: hidden; } .peer:out-of-range ~ .peer-invalid { visibility: visible; }
@media (min-width: 768px) { .col-md-1 { flex: 0 0 auto; width: 8.33333333%; } .col-md-2 { flex: 0 0 auto; width: 16.66666667%; } .col-md-3 { flex: 0 0 auto; width: 25%; }
@media (hover: none) and (pointer: coarse) { .on-touch:block { display: block; } }
@media (orientation: landscape) { .on-landscape:hidden { display: none; } }
@media (prefers-color-scheme: dark) { .dark:bg-darkblue { color: darkblue; } }
Atomic classes have context.
Inline styles are unbounded.
Inline styles don’t have a strategy.
Atomic classes are a system.
Inline styles convey no intent.
.col fl fl fl { oat: left } .col { oat: left } .col { oat: left }
.col { oat: left } .col { oat: left } fi fl fl fl .clear x .col { oat: left }
.clearfix:after { content: ”; display: table; clear: both; }
All abstractions convey intent.
Atomic CSS abstracts visuals, not identity.
Atomic CSS abstracts visuals, not identity.
Inline styles aren’t cacheable.
HTML File updates Time
You can cache inline styles. But that’s pointless.
CSS assets last longer.
HTML CSS File updates Time
Assets freshness speaks volumes on where to spend focus.
A healthy codebase grants you focus.
CSS compositions always have to be mentally compiled.
Well-crafted systems liberate you.
Well-crafted systems liberate you.
That was intense.
Constructive criticism is necessary.
“ Your brain rewards you for classifying new information into existing buckets. Looking for similarities is lower energy than understanding new differences. Matthias Verraes | Software consultant, curator of DDD Europe
“ Proclaiming that the new idea is the same as the old idea gives you permission not to investigate it deeply, stick to the existing reality where you are an expert in the old idea, and the new ones are merely repackaging of your insight. Matthias Verraes | Software consultant, curator of DDD Europe
“ Proclaiming that the new idea is the same as the old idea gives you permission not to investigate it deeply, stick to the existing reality where you are an expert in the old idea, and the new ones are merely repackaging of your insight. Matthias Verraes | Software consultant, curator of DDD Europe
“ There’s such a firehose of information that keeping up with even a single topic is impossible. We should be forgiven for not knowing and understanding and keeping up with everything, even if our job is knowing and understanding and keeping up with everything. Matthias Verraes | Software consultant, curator of DDD Europe
“ But let’s try to make a habit of this. When you feel “oh I get it, it’s just like…”, then follow up with “so what makes the new thing different from the old thing?” Matthias Verraes | Software consultant, curator of DDD Europe
“ But let’s try to make a habit of this. When you feel “oh I get it, it’s just like…”, then follow up with “so what makes the new thing different from the old thing?” Matthias Verraes | Software consultant, curator of DDD Europe
Atomic CSS isn’t a one-size-fits-all.
And sometimes, problems don’t exist.
This sucks.
This is not for me.
This is not for me. But it might, eventually.
Think different critically.
CSS Thank you! sarahdayan.dev algolia.com