Because the border in <span>
only moves the element sideways, but vertically the border is out of the parent container?
Notice in this example that when I use the border in <span>
it does not get left out of div
, however on the top of div
the border stays out ... The border does not seem to take up space vertically, only horizontally. Why does this happen?
OBS: I do not want a way to solve this, I know that for example putting display:inline-block
on span
would solve. What I want to know is why Edge only occupies horizontal space rather than vertical, it pushes the next element to the side, but at the top it does not push, and still stays out of the container , because ?
.container {
width:200px;
height:100px;
border:1px solid black;
}
span {
border:10px solid red;
/* display:inline; */
}
<div class = "container">
<span>text</span><span>text</span>
</div>
<div class = "container">
<span>text</span><br>
<span>text</span><br>
</div>