Design comparison
Solution retrospective
When should you use em over rem? Are there any better practices that I could incorporate into my CSS?
Community feedback
- @orphandeityPosted over 1 year ago
I would suggest using 'rem' units for most things, since the sizing is based on the root font-size and it will give consistent & predictable results.
However, in certain situations, it could be helpful to have the sizing based on the font-size of a particular element. For instance - if you have set the font-size on a button to something other than 1rem, using 'em' units to set the border-radius will give you better control.
I hope that made sense... if not, or if you want more color, here's a good article
Marked as helpful0 - @MeobotPosted over 1 year ago
Honestly, your CSS looks great to me, as a bit of a novice, mind you. I did want to answer your question though. To keep it short, em is used for things you want to scale to the font-size of the parent element, and rem is when those elements don't need to care about the parent font-size.
Excellent job by the way!
Marked as helpful0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord