Is 54 units too many units, or not enough?

General Musings with Kevin Powell · Intermediate ·🌐 Frontend Engineering ·2y ago

Key Takeaways

This video discusses the importance of CSS length units and whether 54 units are too many or not enough

Full Transcript

hello my friend and friends and welcome to my podcast General musings my name is Kevin and this podcast is the audio version of my weekly Sunday newsletter where I talk about whatever is front of mine for me in any given week usually in some way that is related to front-end development as well as share interesting sites and resources that I've come across in the last week as well as share what I've been up to in the week as well this week I'm going to be talking a lot about CSS length units because one of the complaints I hear about CSS is the number of length units that we have with a total of 54 not all of them are supported though yet but we still have 54 in the spec and yeah that is a lot of units but to me this is actually a feature and not a bug first of all about half of the units we have are various versions of viewport units and half of that half of the units are the regular width and height versions with the other half being their logical counterparts so we have like inline size and block size size for example like VW for viewport width and we also have VI for viewport inline or I guess viewport inline size and the other thing is that they keep adding new units like we have a new cap unit and an LH unit for cap height and line height and we have these because there are use cases for them the new line height unit is great for creating vertical Rhythm which has always been a really tricky thing to do with CSS and Adam Argyle recently highlighted this with a codepen example that I'll put a link to in the description SL show notes uh we also have things like the CH and X units and a handful of other really handy ones that you probably will only use in really specific use cases we basically have the big four right we have pixels M REM and percentage that we'll use like what 98 99% of the time and then the other units that they turn out to be really useful but for really Niche use cases now I I get it it sounds like it would be nice to have just one unit that could rule them all right we could rely on that for everything but that's until you start to think about all the different ways that we use our units pixels are fine for like your box Shadow or adding padding on something if you need to and you want to use pixels for it but then you know M serves a really good purpose or having a percentage on a width can be super useful there's times where we need to have different things and then we start getting into those more Niche use cases that I keep talking about with say the X as an example and in case you haven't heard of it the xit it matches the x height of a font which is basically the height of the lowercase letters so let's say you have a decorational suit element and you need that to be the same height as your lowercase letters or maybe you have something like a small tag and you want the text inside of that to be the same height as the lowercase letters of your regular text you basically have two choices here you can magic number your way there with M's or even pixels I guess or you could just say font size 1X and you're done and that's also not to mention that if you went to the m route and then you changed the font family you're using you'll have to magic number it all over again because you'd think that the M's would match but xits are different with every font so it would just sort of fall apart and you just have to be stuck there trying to do it again and that's really annoying so I don't know about you maybe you don't mind magic numbering things but for me the second option of putting a 1x on there it just seems so much better and the same goes for most of the units that we have you don't need to go and memorize them all either but it's good to know there are a bunch of units out there that are relative to different parts of a font's height and then you can just Google them when you run into situations where you think one of them might be useful now from my own experience of talking with people most of the people who complain about this type of thing are people who don't write a ton of CSS they spend most of their time working on backend stuff or writing JavaScript and then you know they get stuck having to write a bit of CSS every now and then and in those situations I don't blame them for getting frustrated because then all of a sudden you're thrown into a situation where you have a ton of different options that are thrown at you when you feel like why do I need all of these I'm just trying to set a font size or something like that so it of course you feel like just having one thing would be a lot simpler but no one solution could fill all of the use cases that we have I mean we could look at JavaScript also here where we went from having one way to create variables with the VAR to now actually having four ways to do it and there were problems with VAR and the way VAR worked and people were a bit annoyed with it so they fixed them by giving us two new options with the let and cons keywords and you know that was awesome each one of those was an improvement over VAR but it still became two different ways to do something when we only had one way to do it before and I guess at that point it was three ways because of course we still had VAR and now they're also adding another one with the using keyword because they realize that as good as let and cons were there's some Niche use cases where another option would be useful and of course here what's once again we're running into this world where most of the use cases for using are more of a niche use case you definitely won't be using it nearly as much as you're using the other two but using has its use cases and you'll be happy to have it when you're in the right situation a little bit like with X and LH units in CSS and of course everything goes through this right we find the limitations of existing Solutions so we come up with new and improved ways to solve those problems so here's to looking forward to the next batch of units that we get because the more we have as far as I'm concerned the better plus figuring out how new units like LH and X works is a lot simpler than figuring out how using works at least for someone who writes CSS all day long anyway but speaking of units actually one of the reasons this was front of mine for me this week is I actually made a flowchart to help people pick the right unit depending on what their situation was or you know what their need was and if you want to find it you can actually just go to what unit.com and I also also made a video where I was going through a bit of my thought process of like you know why did I have these decisions through that flowchart just to give it all a little bit of context and actually the main purpose of the flowchart isn't to go into all of the niche use cases either but more about helping people steer away from the problematic things that I tend to see people doing like the overuse of viewport units and a few other things and actually most of the branches actually end up at some combin of pixels Rems M or percentages which are those big four that I mentioned a little bit earlier now Switching gears a little bit as we head into the other awesome stuff from around the web section we'll dive into the world of accessibility though in a way accessibility has some similarities to what we've been talking about so far because a lot of people struggle to keep up with the best practices of accessibility and actually on that matter one of the questions I actually get asked a lot about is testing with screen readers and Sarah suan has recently put out a very in-depth article that explores how you can get set up to test sites and projects using one the article also links to a lot of other resources like helpful guides and cheat sheets for using them so if it's something that you've ever thought about and maybe you've been hesitant to or you've had trouble setting one up I'd really suggest checking out her article and speaking of Sarah and accessibility I have mentioned this a little while ago but since we're talking about this I figured if you are interested in accessibility Sarah also has a fantastic and really in-depth course on accessibility that I highly recommend and that is it for this week depending on how you're consuming this if you prefer a podcast version of it a video version of it or a written version of it there are links to all of those in the description SL show notes as well as links to everything else that I've mentioned along the way as well thank you so much for listening and until next time don't forget to make your corner of the internet just a little bit more awesome

Original Description

This week, I’m going to be talking a lot about CSS length units because one of the complaints I hear about CSS is the number of length units it has, with a total of 54 (not all of them are supported yet, though). That is a lot of units. But this is a feature and not a bug. Other awesome stuff around the web: - Sara Soueidan’s article on setting up screen readers: https://www.sarasoueidan.com/blog/testing-environment-setup/ What I’ve been up to this week: - The flowchart: https://whatunit.com - The flowchart video: https://youtu.be/Utc_uhvTluk - Keeping up with CSS: The features released in 2023: https://youtu.be/LGRogkgRrOs - Select all siblings of an element using :has(): https://youtube.com/shorts/Ue3VUsZwAJ0?feature=share My primary YouTube channel where I teach frontend development, with a strong focus on CSS: https://youtube.com/@kevinpowell ✉ The written version of my newsletter: https://www.kevinpowell.co/newsletter 💬 Come hang out with other dev's in my Discord Community: https://discord.gg/nTYCvrK Help support my channel 👨‍🎓 Get a course: https://www.kevinpowell.co/courses 👕 Buy a shirt: https://teespring.com/stores/making-the-internet-awesome 💖 Support me on Patreon: https://www.patreon.com/kevinpowell
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from General Musings with Kevin Powell · General Musings with Kevin Powell · 23 of 60

1 Intrinsic Web Design
Intrinsic Web Design
General Musings with Kevin Powell
2 When you feel like you're losing motivation
When you feel like you're losing motivation
General Musings with Kevin Powell
3 Are you sure you want to freelance?
Are you sure you want to freelance?
General Musings with Kevin Powell
4 How I use Notion to help stay on task
How I use Notion to help stay on task
General Musings with Kevin Powell
5 The problem with learning roadmaps
The problem with learning roadmaps
General Musings with Kevin Powell
6 My curse
My curse
General Musings with Kevin Powell
7 The CSS Mindset
The CSS Mindset
General Musings with Kevin Powell
8 My simple technique for a better work/life balance
My simple technique for a better work/life balance
General Musings with Kevin Powell
9 Grids auto-fit syntax is weird at first but its amazing
Grids auto-fit syntax is weird at first but its amazing
General Musings with Kevin Powell
10 When you don’t know where to start
When you don’t know where to start
General Musings with Kevin Powell
11 Making the browser do the work for us
Making the browser do the work for us
General Musings with Kevin Powell
12 Why mobile-first isn't always best
Why mobile-first isn't always best
General Musings with Kevin Powell
13 The problem with following tutorials
The problem with following tutorials
General Musings with Kevin Powell
14 make your navigation work with one line of css  video
make your navigation work with one line of css video
General Musings with Kevin Powell
15 Am I cursed?
Am I cursed?
General Musings with Kevin Powell
16 Keeping up momentum with self-paced learning
Keeping up momentum with self-paced learning
General Musings with Kevin Powell
17 Understanding vs Knowing how to do something
Understanding vs Knowing how to do something
General Musings with Kevin Powell
18 Supercharge your learning
Supercharge your learning
General Musings with Kevin Powell
19 Supercharge your learning
Supercharge your learning
General Musings with Kevin Powell
20 Why is CSS so frustrating for so many people?
Why is CSS so frustrating for so many people?
General Musings with Kevin Powell
21 How people's struggles with CSS evolve over time
How people's struggles with CSS evolve over time
General Musings with Kevin Powell
22 How do you know you're ready to start applying for jobs?
How do you know you're ready to start applying for jobs?
General Musings with Kevin Powell
Is 54 units too many units, or not enough?
Is 54 units too many units, or not enough?
General Musings with Kevin Powell
24 Two important dev skills that don’t get enough attention
Two important dev skills that don’t get enough attention
General Musings with Kevin Powell
25 It took me 6 years to realize I had a great idea
It took me 6 years to realize I had a great idea
General Musings with Kevin Powell
26 Don't rely on this non-existent optimization
Don't rely on this non-existent optimization
General Musings with Kevin Powell
27 Quick one as we head into the holidays!
Quick one as we head into the holidays!
General Musings with Kevin Powell
28 Taking a short break
Taking a short break
General Musings with Kevin Powell
29 Is HTML the easiest, or hardest, to get right?
Is HTML the easiest, or hardest, to get right?
General Musings with Kevin Powell
30 How teaching helped me become a better developer
How teaching helped me become a better developer
General Musings with Kevin Powell
31 Answering your questions - Mailbag episode
Answering your questions - Mailbag episode
General Musings with Kevin Powell
32 A conversation with Una Kravets: The rapid evolution of CSS and hobbies outside of work
A conversation with Una Kravets: The rapid evolution of CSS and hobbies outside of work
General Musings with Kevin Powell
33 It's easy to get stuck in our ways
It's easy to get stuck in our ways
General Musings with Kevin Powell
34 How much browser support is enough?
How much browser support is enough?
General Musings with Kevin Powell
35 A conversation with the person who inspired my channel, Travis Neilson
A conversation with the person who inspired my channel, Travis Neilson
General Musings with Kevin Powell
36 I felt like I was taking a step backward
I felt like I was taking a step backward
General Musings with Kevin Powell
37 A conversation with Clark Sell
A conversation with Clark Sell
General Musings with Kevin Powell
38 The slow adoption of new CSS features
The slow adoption of new CSS features
General Musings with Kevin Powell
39 Why does CSS keep getting more complex?
Why does CSS keep getting more complex?
General Musings with Kevin Powell
40 I hate that people say stuff like this...
I hate that people say stuff like this...
General Musings with Kevin Powell
41 Why You Should Learn CSS Grid Before Flexbox
Why You Should Learn CSS Grid Before Flexbox
General Musings with Kevin Powell
42 Don't overthink it
Don't overthink it
General Musings with Kevin Powell
43 Why competition is a good thing
Why competition is a good thing
General Musings with Kevin Powell
44 ADHD as a dev can be a blessing (or a curse!)
ADHD as a dev can be a blessing (or a curse!)
General Musings with Kevin Powell
45 ADHD can help developers be more creative
ADHD can help developers be more creative
General Musings with Kevin Powell
46 Gain inertia with very small easy tasks
Gain inertia with very small easy tasks
General Musings with Kevin Powell
47 Dev work might be the best job for someone with ADHD
Dev work might be the best job for someone with ADHD
General Musings with Kevin Powell
48 You don't need to be hyper to have ADHD
You don't need to be hyper to have ADHD
General Musings with Kevin Powell
49 Navigating ADHD as a developer
Navigating ADHD as a developer
General Musings with Kevin Powell
50 Nerding out about CSS with Adam Argyle
Nerding out about CSS with Adam Argyle
General Musings with Kevin Powell
51 Is productivity a lie?
Is productivity a lie?
General Musings with Kevin Powell
52 So much new CSS stuff! How can we keep up?!
So much new CSS stuff! How can we keep up?!
General Musings with Kevin Powell
53 Selective learning
Selective learning
General Musings with Kevin Powell
54 Should you use AI to help you learn?
Should you use AI to help you learn?
General Musings with Kevin Powell
55 Navigating Accessibility Challenges in Web Development
Navigating Accessibility Challenges in Web Development
General Musings with Kevin Powell
56 Teaching Front-end, making sense of CSS, and more with Josh Comeau
Teaching Front-end, making sense of CSS, and more with Josh Comeau
General Musings with Kevin Powell
57 Getting more involved with CSS with Miriam Suzanne
Getting more involved with CSS with Miriam Suzanne
General Musings with Kevin Powell
58 The Unplanned Path: Finding Passion in Teaching and CSS
The Unplanned Path: Finding Passion in Teaching and CSS
General Musings with Kevin Powell
59 Navigating CSS Layout Decisions
Navigating CSS Layout Decisions
General Musings with Kevin Powell
60 The future of CSS layouts: a new unified approach
The future of CSS layouts: a new unified approach
General Musings with Kevin Powell

Related AI Lessons

Had my Frontend Developer interview with Capgemini (Application Developer) today, and I wanted to…
Prepare for a frontend developer interview with Capgemini by reviewing JavaScript fundamentals and practicing common interview questions
Medium · JavaScript
10 Frontend Developer Tools to Boost Productivity in 2026
Boost frontend productivity with 10 essential tools for modern web app development
Medium · Programming
10 Frontend Developer Tools to Boost Productivity in 2026
Boost frontend productivity with top 10 developer tools in 2026
Medium · JavaScript
The US Frontend Engineer Market in 2026: A Data-Driven Reality Check (and the Bias That Stops Us Seeing It)
US frontend engineer hiring demand peaked in 2022 and remains flat-depressed in 2026, contrary to common assumptions
Dev.to AI
Up next
The masks we wear | Zora Krstić | TEDxLuxembourgCity
TEDx Talks
Watch →