# No more magic numbers for your breakpoints

## Метаданные

- **Канал:** Kevin Powell
- **YouTube:** https://www.youtube.com/watch?v=4DqIW-gZbHA
- **Дата:** 22.04.2026
- **Длительность:** 5:52
- **Просмотры:** 27,084
- **Источник:** https://ekstraktznaniy.ru/video/49253

## Описание

👉 Start writing CSS with confidence: https://thecascade.dev/courses/css-demystified/?utm_source=youtube&utm_medium=social&utm_campaign=regular-video

🔗 Links
✅ Code from this video: https://codepen.io/editor/kevinpowell/pen/019daad5-af9a-7abd-8f10-c80f0983ddee
✅ CSS Day: https://cssday.nl/
✅ Web you want (free conference!): https://the-web-you-want.org/

✉ Keep up to date with everything I'm up to  https://www.kevinpowell.co/newsletter
💬 Come hang out with other devs in my Discord Community https://discord.gg/nTYCvrK
⭐ Are you a beginner? HTML & CSS for absolute beginners is for you: https://learn.kevinpowell.co
🎓 Start writing CSS with confidence with CSS Demystified: [https://cssdemystified.com](https://cssdemystified.com/)
🚀 Already mastered CSS? Check out my advanced course, Beyond CSS: https://www.beyondcss.dev/

---

Help support my channel
👨‍🎓 Get a course: https://www.kevinpowell.co/courses
👕 Buy a shirt: https://cottonbureau.com/people/kevin-powell
💖 Support me on Patreon: htt

## Транскрипт

### Intro []

Hello my friend and friend. I'm back from Amsterdam. I was there for Smashing Conf where I had an absolute wonderful time. I want to say a really big thank you to Smashing for having me. And yeah, it was really fun. Met a lot of amazing people. Had a really good time. And I'm going to be back in Amsterdam in June. So, if you're going to be uh there around June, we're CSS day. Super excited for that. And I'll put a link to that in the description in case you want to check it out. There is CSS day which is happening and the prices are going up in like a month. So, if you're going to convince your boss to send you, now would be a good time to do it. Uh, then there's also the Web We want conference. It's a free conference happening either the day before or after CSS day. I always forget which one it is. Uh, but I'll put a link to that just in case cuz I know conferences can be expensive. They're putting on an amazing event. Uh, so if you are in the Amsterdam area, I'd recommend you check that out as well. But you're not here for that. You're here to learn about Breakpoints. And I talked all about uh some of this stuff at the conference. My talk was about container queries being amazing. and we're going to see why or this is at least one example of them. Uh and don't if you're like a container queries I'm here for media query stuff. Container queries have fantastic support now. So please don't just run away. Uh they are baseline widely available and support numbers in general are quite good for it. So stick around and see why they are amazing uh or one of the reasons why

### the problem with media queries [1:15]

they're amazing where you can see I have my flex column set up right here. And when I change, you know, this looks fine. And I'm doing this at 50 rem, which is kind of a random number, but I'm doing this with a media query to start with. And the reason I'm doing that is because I want to show that if you change the HTML font size, it will not change the breakpoint. Because even though this is set to REM, when you're using a media query, media queries are an at rule that are like the global scope. So they can't actually see what's happening inside of selectors. And that means you can see here I've actually like broken my layout, right? I have horizontal scrolling cuz the three columns are so narrow with such a big font size. It's exaggerated for demo purposes, but that's fine. Uh if we come down here, uh and I actually or not down to here. If I come and take a look in my

### defining a container [2:00]

HTML, all of this is inside of my article or even main. Let's use our main this time. Uh I used a article when I did this on stage, but we're going to switch this over to a main. And we're going to say that this is a container type of inline size because if you are using container queries, you do have to define a container somewhere. This is one of the limitations of using container queries. Uh and what that means now is the browser can see not only the size of my main but the font size of the main as well. So if I come

### using a container query instead [2:30]

down and I switch this media for an at container, the breakpoint is going to update. And now we see it's all the way out here instead because it's gotten as the REM has gotten bigger on my project. And I'm doing this on my HTML. I could be doing this on the main or other elements as well. And it's going to see the font size. It's just inheriting down into the main. So, it's working fine. Um, but yeah, it it's updated and it's moved the breakpoint all the way out to here. And you came here going, "Well

### changing the unit to create a content-first breakpoint [3:00]

Kevin, you said no more magic numbers and this is a magic number. It's just not in pixels. It's in rem instead. " And you would definitely be right. It is a magic number. But we can change this to use a smarter unit or one that is a content first unit. Uh which I would say is the ch. And I'm going to say 90 ch. You might go, why would you do 90 ch Kevin? That seems just as magic of a number. But it's not. Uh the ch character if you don't know it is the width of a character of your font and all of that. So right now it's you know at this 1. 5 rem size based on the font that I'm using. it's going 90 characters wide. And the reason this is a content first breakpoint. Now, let's just see where it's at. Is it's going to happen when we have about 90 characters long. This is an approximation. So, if you actually take the time to count this, it probably won't be exactly 90. Um, but it's an approximation. And that reason this is a cool breakpoint to have is that means this is happening when I'm about 30 for each one of these, 30 characters wide for each column. And that's a really smart breakpoint to have because that means we're hitting this like smallalish area where things are getting too squished cuz minimum line lengths 25 to 30 characters is getting pretty narrow. And that's about as small as you can get unless you're just on a mobile device and you don't have a choice and you have to go narrower. But if you do have a choice, you probably don't want to get smaller than that. So instead of guessing at a random number, you can use something like the 90CH. And then if I come up to here and I change this back down to a one rem or whatever size you need for your project, it's going to adapt. And now that break point's over here instead. And it's always going to be when we're hitting about 30 characters size for each one. Plus we have like the padding on stuff. So it's a general approximation. But we're doing this not just based on some random magic number that a media query breakpoint uses where you're maybe getting it from the tailwind breakpoints or the bootstrap breakpoints. You're just coming up with something making it big or smaller figuring out where it works. You can actually make informed decisions based on the content which I love. This is such a fun way to work in my opinion and I really like this pattern. It it's one of my favorite ways of using container queries right now. Though there's other really cool things we can do with it such as wrap detection which is really exciting knowing when something is wrapping based on like an intrinsic breakpoint that you might have and I looked at that last week. That video is right here for your viewing pleasure or link down in the description if you need it over there. And if you like this pattern and you want to dive deeper into the world of container queries and see more of the things they can do, my course CSS demystified has a bunch of lessons where it's covering container queries from the basics of how they work, some of the limitations they have, the gotchas and other issues that you can run into with them and awesome patterns and good ways of using them as well. So if you'd like more information on that, the link is down in the description for you to check out. And with that, I'd like to thank my enabler of awesome Johnny as well as all my other patrons and channel members for their continued support. And with that, thank you very much for listening. And of course, until next time, don't forget to make your corner of the internet just a little bit more awesome.
