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 trialRichard Srery
640 PointsHow do i... (2)
How do i give intro a unitless line-height that's 1.6 times larger than the font-size value?
2 Answers
Justin Iezzi
18,199 PointsYou'll want to use the EM unit. EM is relative to the current base font, so 2em would be twice the size. For 1.6x, you would simply use 1.6em.
I may be incorrect here, but I believe you can even use line-height: 1.6;
. I think this would give the same result.
Kevin Korte
28,149 PointsCorrect, it would just be 1.6 here. The browser is smart enough to figure out the rest. The line height will be 1.6x whatever value the font-size is.
Justin Iezzi
18,199 PointsThanks for the clarification. I think the unitless number is preferable then.
Kevin Korte
28,149 PointsUsually yes, line-heights are typically preferred unitless.
This is from css-tricks
The recommended method for defining line height is using a number value, referred to as a "unitless" line height. A number value can be any number, including a decimal-based number, as is used in the first code example on this page.
Unitless line heights are recommended due to the fact that child elements will inherit the raw number value, rather than the computed value. With this, child elements can compute their line heights based on their computed font size, rather than inheriting an arbitrary value from a parent that is more likely to need overriding.