DEV Community

Discussion on: How CSS line-height works and best practices

Collapse
 
kenanberker profile image
Kenan Berker

Thanks for the article!
One small thing I don't think is quite right. You say em is relative to the current element's font-size, but I believe it is actually the parent element's font-size. Which is why it can lead to unexpected results.

Here's a link to the example in the MDN Docs - MDN Docs Example of why to use unitless

Collapse
 
lampewebdev profile image
Michael "lampe" Lazarski

Please have a look here: example

Collapse
 
liaokaien profile image
invisibleTattoo • Edited

In the example in MDN Docs, h1 element inherits line-height: 1.1em from its parent div element; Only in such circumstance the computed line-height of h1 would be 1.1 * its parent element's font-size;