Skip to the page
html reference · grouping

HTML <div> tag

closing tag
required
void element
no
lives inside
anywhere in <body>
typically holds
a block of other elements

Where it goes

Anywhere you want to treat several tags as one thing. It is a block, so it starts on its own line and stretches across the page. You will not see any of that until you add CSS.

Example

<div class="card">
  <h2>Title</h2>
  <p>Some text.</p>
</div>

Open this example in the editor →

Common mistakes

  • Writing the attribute after the tag, like <div> class="x">. It goes inside the brackets: <div class="x">.
  • Expecting a <div> to look like something on its own. It will not, until you style it.
  • Using <div> where a named tag fits. If the box is the main content, the header or the menu, use <main>, <header> or <nav>. Then the structure means something.

Related

Updated 24 October 2026. Practice it in the html route, or read more on MDN.