How are inline-block vertically aligned?
Given the html and the css I would expect the 3 divs to line up horizontally, yet they do not: https://codepen.io/bjorn-pettersen/pen/xxeaaEg
What am I missing?
2 Replies
they all would line up if there was content, but the first and last div are empty
inline elements are lined up to the text baseline, but without text and having a top/bottom margin, the baseline gets disrupted
margin-block (top/bottom) on inline elements is asking for issues. they distrupt the content flow, which you typical don't want with inline elements
I don't know what you want to achieve, but you could use margin-inline (left/right) on the divs and a padding-block (top/bottom) on the section
It's mainly for my own understanding. Good catch on the y-margin issue. Changing
display: inline
to display: inline-flex; align-items: end;
is closer to what I was expecting (although I can see why that was wrong).