Lecture
The div Tag
The <div> element in HTML is a block-level element used for partitioning or grouping content on a webpage.
The <div> element is used in the following form:
div Tag
<div> <!-- Space to insert content --> </div>
The <div> element is useful for applying styles or layouts to grouped content, or for dynamically manipulating elements with JavaScript.
For example, the following HTML code uses the <div> element to group a section title and content.
Grouping a Section with div Element
<div> <h2>Section Title</h2> <p>Section content</p> </div>
When grouping sections, it is more semantically appropriate to use the <section> element.
The <div> element can also be used as an empty element, and you can add CSS classes and identifiers (ids) to create selectors for targeting specific partitions.
Lecture
AI Tutor
Help