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 Using calc() in Padded Containers

Giovanni Dalla Rizza
Giovanni Dalla Rizza
10,637 Points

em value when it isn't declared

What's the em's value when it isn't declared in the .body?

1 Answer

Erik Nuber
Erik Nuber
20,629 Points

An em is equal to the currently specified point size.

The em unit’s value will be derived from whatever is actually inherited. If no font size is specified anywhere in the document, then the value of a single em unit will be equal to 16px, which is the default.

ex:

.myClass {
   font-size: 20px;
   width: 1em;
   height: 2em;
}

Here the width will be 20px and the height will be 40px.

with nothing declared for a font-size all the way up to the document node

.myClass {
  width: 1em;
  height: 2em;
}

This would default to 16px and width would be 16px and height 32px.

Ben Schroeder
Ben Schroeder
22,818 Points

The default is set by the browser/user. It won't always be 16px.

Erik Nuber
Erik Nuber
20,629 Points

@ben you can verify this here. 16px is default if the user has not declared anything.

http://www.w3schools.com/css/css_font.asp