HTML โ€” Lesson 11

Block vs Inline Elements

Understanding element display behavior and how to change it.

By Majed Qandeel ยท Jul 26, 2026 ยท Lesson 11 of 25

Block vs Inline Elements

HTML elements have a default display behavior: they either start on a new line (block) or flow within text (inline).

Block-Level Elements

Block elements start on a new line and take up the full available width.

<!-- Block elements always stack vertically --> <div>Full width block</div> <p>Another block</p> <h1>Heading is a block</h1> <ul>List is a block</ul> <table>Table is a block</table>

Inline Elements

Inline elements flow within text and only take up as much width as needed.

<p> This is a paragraph with <strong>bold</strong>, <em>italic</em>, and <a href="#">links</a> all flowing on the same line. </p>

Key Differences

PropertyBlockInline
New lineYesNo
Width/HeightRespects (full width)Ignores
Margin (top/bottom)YesNo effect
Margin (left/right)YesYes
PaddingAll sidesHorizontal only (visual only)
Examplesdiv, p, h1-h6, ul, lispan, a, strong, em, img

Changing Display with CSS

/* Make a span behave like a block */ span.block-span { display: block; width: 200px; height: 100px; background: lightblue; } /* Make a div flow inline */ div.inline-div { display: inline; } /* Inline-block: inline flow + width/height */ .badge { display: inline-block; padding: 4px 12px; background: #333; color: white; border-radius: 4px; }
Tip: For modern layouts, use Flexbox or Grid instead of relying on block/inline behavior. But understanding these basics is essential for working with inline elements like badges, tags, and links.

Practice what you learned in the Deoit Editor โ€” a free, browser-based code editor.

Open Editor โ†’
\r\n