Difference between box model elements i.e Block elements, Inline elements and Inline-Block elements
Gyanswarup Mohanty
Feb 02, 2022
Block Elements
- Elements visualise as blocks.
- Consumes the 100% parent’s width.
- Comes vertically one after another.
- Box model applies as shown.
- Example:- div, p, header etc.
Inline Elements
- Elements occupies only the content’s space.
- Comes one after another means there is no line break between elements.
- Box model is different as height and width do not apply.
- Padding and margins are only applied horizontally i.e only left and right.
- Example:- a, img, input etc.
Inline-Block Elements
- Looks like inline from outside but behaves like block from inside.
- Elements occupies only the content’s space.
- Comes one after another means there is no line break between elements.
- Box model applies as shown.