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 trial

CSS

my pixel working out doesn't match what's displayed?

html { font-size: 20px; }
h1 { font-size: 2rem; }

1rem = 16px so 4rem = 64px

so 64px + 20px (inherited from html) = 84px
But when inspected the h1 shows 80px ? No padding either.

1 Answer

Martin Balon
Martin Balon
43,651 Points

Hi Jason,

rem is based on the root of the element. So if you set font-size in html (which is root in this context) as 20px then 1 rem is 20px. So if you set font-size of h1 to 2rem the result is 40px and h1 set to 4rem is therefore 80px.

oh root of the element yes it is isn't it, I forgot. thanks