Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAlex Deward
309 PointsWhy do you use rems here?
Guil Hernandez Why do you use rems in this video? You always used ems before. Is that important?
Thanks in advance.
2 Answers
jason chan
31,009 PointsTravis Explains rems and ems here in this video. Rem is the root pixel size of font. em is the enclosed in scope size of font. times the enclosed em in scope.
Austin Whipple
29,725 PointsTo expand further on Jason's answer:
Because ems adjust size based on the font size of the parent element, they can be variable across the HTML document. For instance, if I set the font size of an H3 to 30px while the font size of the body element is 18px, the value of 1em is different for each, so setting things like padding and such within each element would be different. By using an rem, you're guaranteeing that they'll be the same regardless of where it's used. The rem always bases it's value on the font size of the root html element.
There are valuable uses for each and Guil uses both in different videos to show their respective value.
Graeme Oxley
8,931 PointsGraeme Oxley
8,931 PointsEssentially he used it to "reset" the value back to the root value. Hence the use of 1rem; he only wanted it to be 100% of the root value.