When an element is inline or displayed inline, and a line height is set… what is theactual height of the element ( for background purposes)
example :
ul{background: yellow; font-size: .7em; float: left; text-align: center; padding:0; margin:0}
ul li { padding:0; margin:0; display: inline; line-height: 2.15em}
ul li a { padding:0 .5em;line-height: 2.15em}
ul li a:hover {background:pink;}
Here my list seems to display horizontally, as intended, with a height of 2.15 em, also as intended, but when I hover a link only the te actual text has a pink bg, where as I would have expected the bg to include the entire line height…
Hi, the line-height specifies the height of each line (aka the spacing between each line)
The actual content won’t get the increased height thus the pink background won’t cover the entire line-height. Line-height is sorta like a margin between each line, if you want to think about it like that :).
Putting a border around the anchor will show you the height of the anchor (notice the line-height doesn’t affect the height)
In your example you set the yellow background on the parent block element but you changed the background color on the child inline element whose background only stretches as far as the “content area” of that inline element.
The background of an inline element does not include it’s line height.
If you applied the yellow background to the anchor to start with you would see that only the content area (the font size of the element) is covered.
If you float the lists or make then display:block then they take on the full height of the parent.
It’s basically the difference between inline and block elements again.