What exactly is the difference between the inline
and inline-block
values of CSS display
?
splattne's answer probably covered most of everything so I won't repeat the same thing, but: inline
and inline-block
behave differently with the direction
CSS property.
Within the next snippet you see one two
(in order) is rendered, like it does in LTR layouts. I suspect the browser here auto-detected the English part as LTR text and rendered it from left to right.
body {
text-align: right;
direction: rtl;
}
h2 {
display: block; /* just being explicit */
}
span {
display: inline;
}
هذا عنوان طويل
one
two
However, if I go ahead and set display
to inline-block
, the browser appears to respect the direction
property and render the elements from right to left in order, so that two one
is rendered.
body {
text-align: right;
direction: rtl;
}
h2 {
display: block; /* just being explicit */
}
span {
display: inline-block;
}
هذا عنوان طويل
one
two
I don't know if there are any other quirks to this, I only found about this empirically on Chrome.