Use div element to create structures

Description

The div element doesn't have a specific meaning. div element creates structure.

The div element is the block equivalent of the span element. Block element starts new line while inline element stays in the same line.

Example

The following code uses the div Element.


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

  <div class="favorites">

    <p>
      This is a test.
    </p>

    <p>
      This is another test.
    </p>
  </div>

  <p>
    This is a test.
  </p>

</body>
</html>

Click to view the demo





















Home »
  HTML CSS »
    HTML »




HTML Introduction
HTML Document
HTML Section
HTML Group Content
HTML Text Marker
HTML Table
HTML Form
HTML Embed