HTML <div>
Published Jun 10, 2021Updated Jul 1, 2022
Contribute to Docs
The <div> element represents a generic division of content. It has no semantic meaning, but will separate its contents from the rest of the document.
Syntax
<div><!-- Content lives here --></div>
The <div> tags that wraps around a block of HTML. By default it is a block element, meaning its contents will start on a new line and the content that follows will start on a new line.
Example
A <div> is a good choice when no other tag matches the content type. Additionally it is often used to help style an entire page, or sections of a page via the class or id attribute.
<html><head> </head><body><!-- This div wraps the entire site applying the styles from the dark-mode class --><div class="dark-mode"><!-- Site content lives here --></div></body></html>
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn HTML on Codecademy
- Front-end engineers work closely with designers to make websites beautiful, functional, and fast.
- Includes 34 Courses
- With Professional Certification
- Beginner Friendly.115 hours
- Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.
- Beginner Friendly.7 hours