In CSS, display
can have values of inline
and inline-block
. Can anyone explain in detail the difference between inline
and inline-block
?
I searched everywhere, the most detailed explanation tells me inline-block
is placed as inline
, but behaves like block
. But it does not explain what exactly "behave as a block" means. Is it any special feature?
An example would be an even better answer. Thanks.
Inline elements:
Block elements:
Inline-block elements:
From W3Schools:
An inline element has no line break before or after it, and it tolerates HTML elements next to it.
A block element has some whitespace above and below it and does not tolerate any HTML elements next to it.
An inline-block element is placed as an inline element (on the same line as adjacent content), but it behaves as a block element.
When you visualize this, it looks like this:
The image is taken from this page, which also talks some more about this subject.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With