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 CSS Basics (2014) Understanding Values and Units Em Units

Enemuo Felix
Enemuo Felix
1,895 Points

Using em

Which parent element will the P element below be relative to in this case ?

<div> 
 <h1>This is the first element</h1>
<h2>This is the second element</h2>
<p> This is the third element</p>
</div>
body {
 font-size: 2em;
}

h1 {
 font-size: 1.625em;
}

h2 {
 font-size: 1.25em;
}

p {
 font-size: 1em;
}

The p element is a child of the div and a sibling of the h2 and h1

Ashley Georges Souffrant
Ashley Georges Souffrant
2,828 Points

The parent element in this case would be the <div> element or tag therefore relative. The <h1> and <h2> tags are child elements just as <p>. This includes 1 parent element <div> and 3 children elements <h1>, <h2> and <p>. Hope this helps !

Enemuo Felix
Enemuo Felix
1,895 Points

Ashley Georges Souffrant Very Helpful! However, you might want to consider changing your comment to an answer. Thumbs up to Kristian and Steven too. You guys are amazing!

1 Answer

you can use rem which ties it to the root.