I'm wondering myself, why an empty div, that has the display:inline-block
style behaves differently from a div that cointains text. It somehow seems to add some top-padding to following elements, that cannot be removed.
HTML
<p>
<div class="a">A</div><div class="b">B</div>
</p>
<p>
<div class="a"></div><div class="b">B</div>
</p>
CSS
.a {
width:20px;
height:20px;
display:inline-block;
background-color:red;
}
.b {
background-color:orange;
line-height:20px;
font-size:12px;
display:inline-block;
}
Output
Can someone explain this behavior?