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

HTML How to Make a Website Customizing Colors and Fonts Pick Fonts and Set Relative Units

Carlos Enrique Castañeda Gutiérrez
Carlos Enrique Castañeda Gutiérrez
13,886 Points

Question about "em" units

Nick said em units are relative to the default font-size. Who determines the "default" font-size; the browser or the font-family?

Example 1: IE default size for Changa One might be 16px and in Chrome 18 px? Example 2: Default size for Changa One might be 16px for all browsers and Sans-Serif 18px for all browsers?

Thanks very much

2 Answers

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,252 Points

The default size is always the user agent so that's the web browser unless you explicitly set a font-size for font family. :-)

Bare in mind though if you're setting an element an em font size it then becomes the default size for any child elements.

```The em unit is a relative unit based on the computed value of the font size of the parent element. This means that child elements are always dependent on their parent to set their font-size. For example:

https://css-tricks.com/almanac/properties/f/font-size/#article-header-id-3
Carlos Enrique Castañeda Gutiérrez
Carlos Enrique Castañeda Gutiérrez
13,886 Points

Thanks for your answer, now it's clear to me. The "container" example in the link, clarify me the utility of using "em" units.

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 91,252 Points

I'm sorry, I'm not sure what you mean by "utility" but relative units like "em!" are more recommended as you have more control of the size of your fonts element to element.

If you were to use absolute elements like px, each font you would use would show it precisely in the given size and are not relative to anything except maybe the Root element! :)

Carlos Enrique Castañeda Gutiérrez
Carlos Enrique Castañeda Gutiérrez
13,886 Points

English isn't my mother tongue, I wanted to say the "benefit" or "advantages" of using em units.