Skip to content
0:00 / 0:00

#cssunits#em#rem

Are you using the right CSS units?

Kevin Powell

1M subscribers • 13 videos on Hallway

YouTube
  • Recommended by 4 people: 4 in engineering communities.
  • A classic. People kept recommending it from 2021 to 2026.

Beginner. No background in the topic needed.

511K views5 years ago4 recommendations

Web developmentCSS and layout

Kevin Powell explains the rules of thumb for choosing between different CSS units like em, rem, and pixels for responsive web design.

There are a lot of different units that we can use when writing CSS, in this video I give some general rules of thumb of which ones are best suited for which situations. Zell's article on media queries: zellwk.com/blog/media-query-units/ Em vs. Rem: youtu.be/_-aDOAMmDHI Using clamp() for fonts: youtu.be/U9VF-4euyRo The issue with em with font sizes: youtu.be/pautqDqa54I Viewport units: youtu.be/IWFqGsXxJ1E The ch unit: youtu.be/dgbFtMBOMlA #css -- Come hang out with other dev's in my Discord Community 💬 discord.gg/nTYCvrK --- Keep up to date with everything I'm up to ✉ kevinpowell.co/newsletter --- Help support my channel 👨‍🎓 Get a course: kevinpowell.co/courses 👕 Buy a shirt: teespring.com/stores/making-the-internet-awesome 💖 Support me on Patreon: patreon.com/kevinpowell --- My editor: VS Code - code.visualstudio.com/ --- I'm on some other places on the internet too! If you'd like a behind the scenes and previews of what's coming up on my YouTube channel, make sure to follow me on Instagram and Twitter. Instagram: instagram.com/kevinpowell.co/ Twitter: twitter.com/KevinJPowell Codepen: codepen.io/kevinpowell/ Github: github.com/kevin-powell --- And whatever you do, don't forget to keep on making your corner of the internet just a little bit more awesome!

Why it's here

4 people recommend this

What people say. Recommended as a helpful guide and clear explanation for choosing the right CSS units for responsive websites.

u/MistrSirin r/Frontend • Recommends

On “Which unit should I use for a responsive website?”

I know it's not a unit, but using max-width for elements was a eye opener when I started making responsive websites. It means what if your element doesn't have enough room to be your desired width, it shrinks to fit inside the parent. Also this video by Kevin Powell is pretty helpful with units link to this video

u/asartaloin r/Frontend • Recommends

On “how do you properly size elements?”

It would be difficult to give any advice without the specifics of your issue. However there are some general guidelines on how to use CSS units. I think this video from Kevin Powell is a good introduction: link to this video

u/icantsI33pin r/Frontend • Recommends

On “When to use Rem, Em, VW/VH, %, PX?”

This is a really good explanation of it: link to this video

u/GamingBroccolliin r/Frontend • Recommends

On “Tips for CSS units? What are your go to units in 99% cases?”

I saw a video of guy setting font-size to ~~like something slightly above~~ 62.5% and then if you put 2.1rem it is equal to that number x10 in pixels. so 2.1remx10 = 21px [video go to 1:30 for better explanation.