Code:
<div style="font-size:12px">abc</div>
On my chrome browser, the height of this div is 14px, which means the actual value of line-height of the div is 14px. How about on other browsers? Does W3C standard address this?
Code:
<div style="font-size:12px">abc</div>
On my chrome browser, the height of this div is 14px, which means the actual value of line-height of the div is 14px. How about on other browsers? Does W3C standard address this?
The line-height
for div
elements defaults to a user agent value of normal
. According to MDN, the interpretation of normal
is user-agent dependent.
https://developer.mozilla.org/en-US/docs/Web/CSS/line-height#values
normal
Depends on the user agent. Desktop browsers (including Firefox) use a default value of roughly 1.2, depending on the element's font-family.
Your example is 14.4px
height on firefox. On Safari it's 14px
.
https://www.w3schools.com/cssref/pr_dim_line-height.asp
https://developer.mozilla.org/en-US/docs/Web/CSS/line-height
line-height:normal
Depends on the user agent. Desktop browsers (including Firefox) use a default value of roughly 1.2, depending on the element's font-family.
Also usefull: http://smad.jmu.edu/shen/webtype/lineheight.html
I found one blog related to line-height with other height references in HTML/CSS. LINE-HEIGHT
Hope this will help you to understand the concepts of line-height.