Web Analytics

Block vs Inline Elements

Intermediate ~8 min read

Two Display Types

Every HTML element has a default display value. The two most common are block and inline.

Block-Level Elements

Block elements:

  • Always start on a new line
  • Take up the full width available
  • Have top and bottom margins

Common block elements: <div>, <p>, <h1>-<h6>, <ul>, <li>, <table>, <form>

HTML
CSS
JS

Inline Elements

Inline elements:

  • Do not start on a new line
  • Only take up as much width as needed
  • Cannot have top/bottom margins (only left/right)

Common inline elements: <span>, <a>, <strong>, <em>, <img>, <input>

HTML
CSS
JS

Visual Comparison

See how block elements stack vertically while inline elements flow horizontally:

HTML
CSS
JS
CSS Tip: You can change display behavior with CSS: display: block; or display: inline;

Quick Quiz

Which element is a block-level element by default?

A
<span>
B
<a>
C
<div>
D
<strong>