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 trialJack Hou
6,975 PointsQuestion about the use of em
So in many videos, there is the use of em when choosing font sizes. From what I know so far, 1 em is equal to 16px, but why do some of the videos say in certain example that 1 em is equal to 18px. Did they change the base font size ? if so, how do you do it?
Jack Hou
6,975 PointsSo 1 em can be whatever you want it to be as long as it's the base font size in the body? so if i declare body { font-size : 72px } then 1em will be 72px?
Thanks for taking the time to answer!
John Locke
15,479 PointsYes. Whatever you set the base font-size to, that new size will become 1em.
Jack Hou
6,975 Pointsthanks!
1 Answer
qdzfplofsk
22,025 PointsJust adding that em units cascade or are relative to their parent's size (not always the body) which can cause extra work in resetting nested containers etc. back to 1em. If you want a unit that is based on the html body page only it's better to use the CSS3 rem unit (root em) which is supported in modern browsers and ie9+ or just provide a px fallback.
John Locke
15,479 PointsJohn Locke
15,479 PointsHi Jack: 16px is usually equal to 1em, as most browsers have it set like that by default. To change the base size, simply declare something like body {font-size: 18px;} in your CSS.