HTML - div Tag



The HTML <div> tag is used for defining a section of your document. With the div tag, you can group large sections of HTML elements together and format them with CSS.

The difference between the div tag and the span tag is that the div tag is used with blocklevel elements whilst the span tag is used with inline elements.


<!DOCTYPE html>

      <title>HTML div Tag</title>
      <link rel = "stylesheet" href = "style2.css">

      <div id = "contentinfo">
         <p>Welcome to our website. We provide tutorials on various subjects.</p>


Here is the csss file style2.css

#contentinfo p { 
   line-height: 20px;
   margin: 30px;
   padding-bottom: 20px; 
   text-align: justify;
   width: 140px;
   color: red; 

This will produce the following result −

Global Attributes

This tag supports all the global attributes described in HTML Attribute Reference

Specific Attributes

The HTML <div> tag also supports the following additional attributes −

Attribute Value Description
autofocus html-5 autofocus Specifies

Event Attributes

This tag supports all the event attributes described in HTML Events Reference

Browser Support

Chrome Firefox IE Opera Safari Android
Yes Yes Yes Yes Yes Yes

Useful Video Courses


HTML Online Training

19 Lectures 2 hours

Anadi Sharma


HTML5 Online Training

16 Lectures 1.5 hours

Anadi Sharma


HTML Web Development

18 Lectures 1.5 hours

Frahaan Hussain