Why do the div with the classname first have 2px more than the image.(Inspect from Google Chrome), even though I set the line-height
to 1, which mean the line gap is 0.(div tag with second classname have the correct height.)
Code
.first {
background-color: blue;
line-height: 1;
}
.first>img {}
.second {
background-color: red;
line-height: 1;
}
.second>span {
display: inline-block;
}
<div class="first">
<img src="https://png.pngtree.com/png-vector/20190710/ourmid/pngtree-user-vector-avatar-png-image_1541962.jpg" alt="any picture">
</div>
<hr>
<div class="second">
x<span>x</span>
</div>