-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The 62.5% Font Size Trick #97
Comments
I really enjoyed you article. I too have been using REMs at a 1/10 ratio and setting the |
Great article! |
This was such a good article. Thank you. I am learning CSS via The Odin Project, and will use this technique here on out. My question (and maybe this could be another follow up article)... when and where should I use EM? (Or should I just get used to sizing everything in REM?) I would imagine that padding paragraphs, buttons etc with EM would be useful? |
@MondoBurrito Good question! I tend to use rems for everything, but I've recently been debating whether this is actually a good practice. I haven't quite made up my mind yet. If you're interested, there was a good thread about it on Twitter. The takeaway seems to be that you may want to use I tend to avoid |
This is a good idea, unless it isn't. |
@lcech That's actually a really good point and something I hadn't considered. While the technique outlined in this article can be useful, it could also make it difficult to incorporate other libraries (CSS or component) in the future. On the other hand, I tend to prefer unstyled component libraries like Radix UI since they allow you to keep your own conventions. It's definitely a tradeoff. Thanks for bringing this up! |
Excellent article. These classes are referencing pixel sizes as they will be in a default, uncustomized browser. But they will output rem values. So then when I see the designer has used 12 px, I can go "text-px-12". Seems like a simple workflow?
|
Is there any evidence that, for modern browsers, setting something like I guess another way to say it: scaling font size seems like a feature of a previous generation of browsers, whereas modern browsers all advocate zooming (and make it easy to do), which works regardless of that setting, so I can't see any reason why |
@matthew-dean Honestly, I'm not too sure! Fwiw, I recently moved away from the Edit: See my related post on why you should use rems for font size. There, I've linked to an article from 24a11y on why pixels aren't great for responsive scaling (even though you technically can still zoom the page). |
I actually tried using the 6.25% approach to make the translation super simple from my figma artboard(1440px) to breakpoint(1440rem), then inspired by the website of anytype and how they use a font-sizer custom property as the multiplier to make root font-size fluid. I loved the simplicity and the very little need to tweak anything beyond when the initial numbers are thoughtfully locked in. The only downside is, as @lcech pointed out, when i decided to pull in other libraries. anything that touches sizing needs some scrutiny for them to work properly within this new construct. But all in all, I wanted to echo your stand regarding the validity of the 62.5%, and by extension, even the 6.25% as well. |
Using 6.25% will bring your font size under WebKit's 9px "readable" minimum for scaled font sizes, which will cause the rest of your website to scale funny. |
No description provided.
The text was updated successfully, but these errors were encountered: