Skip to main content

<div> - Container

The div (container) is an element used for encapsulating multiple elements as a composite. It can be defined by using a pair of <div> and </div> tag.

It is really important to know how to use container element because it allows us to create a more advanced page layout, combined with CSS for positioning and styling the elements in the composite. It would be very hard, or even impossible, to nicely layout a composite without the help of container.

You can use div (container) to:

  • Define a set of elements as a composite in a complex page layout.
  • Organise a page layout into several sections where each section may have their own purpose in providing functionality to the user, e.g. one section is defined for displaying a list of items, while another section is for displaying advertisement.
  • Set the position of a group of elements relative to the page with a help from the provided CCS.

Usage Example

Loading Code Editor...

Output: