Skip to content

HTML Tutorial Block, Inline and Containers

HTML Block and Inline Elements: How Elements Flow on the Page

Lesson 35 of 81 2 min read By Deepak Paswan Updated Oct 4, 2026

Every HTML element has a default display behaviour. Two of them cover most elements: block and inline.

Block elements

A block element starts on a new line and stretches across the full width of its parent. Paragraphs, headings, lists and div are block elements.

index.html
HTML
<style>
  p { background: #fff3ec; }
</style>
<p>First paragraph</p>
<p>Second paragraph</p>

Each paragraph’s background fills the whole row.

Inline elements

An inline element sits within a line of text and takes only as much room as its content. Links, strong, em, span and img are inline.

index.html
HTML
<style>
  a { background: #fff3ec; }
</style>
<p>Read <a href="#">the guide</a> and <a href="#">the FAQ</a> today.</p>

The backgrounds fit the link text only.

Quick reference

BlockInline
div, p, h1 to h6span, a, strong, em
ul, ol, liimg, code, abbr
section, article, headerbutton, input (inline-block)
table, formlabel, br

Nesting rules

  • Block elements can usually contain other blocks and inline elements.
  • Inline elements should contain only text and other inline elements.

Changing the behaviour

CSS can change it with the display property: display: block, display: inline or display: inline-block. A link can become a block, and a div can become inline.

warning
Putting a block inside an inline element
An a can wrap a block in modern HTML, but a span wrapping a div is invalid. If you need a block-level container, use a div.