Given the following two blocks of HTML markup:
<div style="overflow:auto; line-height:22px;">
<div style="float:left; display:inline;">Write</div>
<div style="float:left; display:inline; font-size:20px;">on the</div>
<div style="float:left; display:inline; font-size:20px;">same line</div>
</div>
<div style="line-height:22px;">
<span>Write</span>
<span style="font-size:20px;">on the</span>
<span style="font-size:20px;">same line</span>
</div>
Why do they display the same thing differently? A span is an inline element, yet the text “Write” vertically aligns differently with “on the” and “same line” regardless of the div displaying as inline. Shouldn’t it render the line in exactly the same manner?
Your divs are floating. They cannot be inline if they’re floating.
If you remove the floats (and subsequently the
overflow: autoon the parent since that won’t be necessary), then they’ll behave like inline elements: