I am surprised that inline elements do not line up even though they have mathematically the same height.
One element has a height of 50px and the others have a height of 44px + 3px padding (= 50px height).
I have found some posts that say to use vertical-align: top;. But it is not clear to me why this is related to the content.
Without content they are displayed in a line, but as soon as I add content (text), the elements with height 50px are pushed down.
What is the reason for this and how can I change it?
HTML-Code
<div>
<span class="x">x</span>
<span class="y">x</span>
<span class="x">x</span>
<div>
CSS
div {
height: 50px;
}
span {
display: inline-block;
border: 1px solid black;
}
.x {
height: 50px;
}
.y {
height: 44px;
padding: 3px 0;
}
Thanks a lot