I've only just realised that anchor tags with a background will only inherit their line-height and you can only set it directly by setting the anchor to display: inline-block;
Why is this?
http://jsfiddle.net/moefinley/3H3y5/
ul li a {
display: inline-block;
line-height: 20px;
}
Here is root cause :
content-area = in non-replaced elements, the box described by the font-size of each character in the element, strung together; in replaced elements, the intrinsic height of the element plus any margins, borders, or padding
inline box = the addition of (half-)leading to the content-area for each element; for non-replaced elements, the height of the inline box of an element will be exactly equal to the value for line-height; for replaced elements, the height of the inline box of an element will be exactly equal to the intrinsic height of the element plus any margins, borders, or padding
line-box = the box which bounds the highest and lowest points of the inline boxes which are part of the line
The following behaviors fall out of this description:
So your line-height for a
with background works fine only when you mark it as block element using inline-block
. And with default behavior it will just stretch the line height without stretching background.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With