Div tag in HTML

Div tag in HTML

The div tag in html:-

The div tag in html to create a division or a section in an HTML page.  This element is used as a container for HTML elements – which is then styled with CSS or manipulated with JavaScript. By marking related content as a <div> and giving it a unique “id” or indicating that it is part of a class, you give context to the elements in the grouping. 

Note: By default, browsers always place a line break before and after the <div> tags.

See the Example below:-

 
 
<body>
       <div id =“my_about_us”>
              <h1>About Us</h1>
              <img src=”xyz.jpeg”>
               <p> website’s about us page</p>
        </div>
</body>
 

Here is another common use of a div used to break a page into sections for layout purposes. In the above example, a heading, image, and paragraph are enclosed in a div and identified as the “my_about_us” division:
In the example above, a <div> element is used as a container to group an <h1>, <img> and <p> elements and placed a id attribute named- “my_about_us” to style div container with style rule;

See the example below:

div element style example image

See the Result:-

div element example result image