The div tag

The div tag defines a block that combines other tags. The tag itself does nothing, but when combined with the class and id attributes, it allows you to access a group of combined tags through CSS.

Example

Let's use the div tag to group several paragraphs and apply some styles to the group:

html<div id="elem">
  <p>text</p>
  <p>text</p>
  <p>text</p>
</div>
css#elem {
  color: red;
  padding: 10px;
  border: 1px solid black;
}

Результат:

See also

  • tag span,
    which allows you to select a piece of text
  • tag section,
    which also groups tags