HTML div - how to use <div> tag

The HTML <div> - is used to define a section within a HTML document. The div tag is usually used to group a number of elements that can be styled. Prior to HTML5, the div tag was usually used to define the layout of a web page, for example, the header, footer sections of a web page.

Browsers usually place a breaking space at the end of the tag.


The tag supports the global and event attributes.


<div style="color:red"> <h3>h3 heading</h3> <p>Dummy paragraph.</p> <div>Nested div</div> </div>