What is the difference between inline-block
and block
?
And when should you use those values?
What is the difference between inline-block
and block
?
And when should you use those values?
This page illustrates the difference pretty well.
The functional difference is that:
Compared to
display: block
, the major difference is thatdisplay: inline-block
does not add a line-break after the element, so the element can sit next to other elements.
You can think of the difference as that you want to use the behaviour of block
elements inline, since normal inline
elements don't allow such behaviours.
The major difference is that inline-block does not add a line-break after the element, so the element can sit next to other elements in a line (as an inline element)
So additionally inline-block allows setting both width and height on the element. Inline elements don't allow set width and height.