Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between baseline of empty and non-empty inline blocks

Tags:

css

div {
    display: inline-block;
    width: 100px;
    height: 100px;
    background: #aef;
    vertical-align: baseline;
}
base <div>×</div> <div></div> line

The empty inline block is aligned differently from the one containing text. This can be fixed by specifying a different vertical-align value, but I wonder why this is happening. Can you point to a relevant part of CSS specification?

like image 395
Alexey Lebedev Avatar asked Nov 21 '11 17:11

Alexey Lebedev


1 Answers

From CSS2: Line height calculations

vertical-align: baseline — align the baseline of the box with the baseline of the parent box. If the box doesn't have a baseline, align the bottom of the box with the parent's baseline.

like image 160
Alexey Lebedev Avatar answered Sep 19 '22 18:09

Alexey Lebedev