<div> - HTML CSS HTML Tag

HTML CSS examples for HTML Tag:div

Introduction

The div element marks the structure. It is used to group other elements.

We can add style to the div element to change the layout.

The div element is the block element equivalent of the span element.

The div Element summary

Item Value
Item Description
Elementdiv
Local Attributes None
Tag Style Start and end tag required
New in HTML5 No
Changes in HTML5 None

Style Convention

div {
   display: block;
}

Using the div Element

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
   <head> 
      <title>Example</title> 
      <style>
.favorites {<!--from  w  w w .  j  a  v  a  2s .  c o m-->
   background:grey;
   color:white;
   border: thin solid black;
   padding: 0.2em;
}

      </style> 
   </head> 
   <body> 
      <div class="favorites"> 
         <p>I like CSS and HTML.</p> 
      </div>  
   </body>
</html>

Related Tutorials