agyanadda@gmail.com

HTML Block and Inline Elements

HTML Layout & Structure 1 min read Updated Nov 30, 2026 Topic 16 of 33

Every HTML element is either block or inline by default.

Block elements

Start on a new line and take the full width. Examples: <div>, <p>, <h1>–<h6>, <ul>, <table>, <form>.

Inline elements

Stay in the same line and take only the space they need. Examples: <span>, <a>, <strong>, <img>, <input>.

div and span

  • <div> is a generic block box — used to group sections for styling.
  • <span> is a generic inline box — used to style part of a sentence.

Example

Example — div vs span HTML
<div style="background: #e3f2fd; padding: 10px;">
  This is a div. It takes the full width.
</div>
<div style="background: #fce4ec; padding: 10px;">
  Another div starts on a new line.
</div>

<p>
  This sentence has a <span style="color: red; font-weight: bold;">red span</span> inside it,
  and it stays on the same line.
</p>

Test Yourself With Exercises

Exercise 1 Multiple Choice

Which element is inline by default?

Exercise 2 True / False

A block element always starts on a new line.

Frequently Asked Questions

Yes, with CSS: display: inline; or display: block;. You can also use display: inline-block or flex.