Are there any drawbacks(browser/device inconsistency…) in specifing line height without unit?
Example:
body {
line-height: 1.5;
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In most cases, it’s actually better to use unitless line-height – see
Of course, there are exceptions. The first one that comes to mind is when you have a block element with a known
heightand with one line of text in it and you want to center that line of text vertically – I find that the easiest way to do that is to use aline-heightthat’s equal to theheightof the block element.[Just in case, for anybody who doesn’t know what’s the deal with unitless
line-height.]Suppose you have an element with
font-size: 14px. It doesn’t matter where it was set, whether it’s inherited or not, if you set it yourself or it came from the user agent stylesheet. The element hasfont-size: 14px.Now, if you set, let’s say
line-height: 1.5for the same element, this will be translated into pixels as 1.5 * 14px = 21px. So your computedline-heightwill be21px.