Html <div> tag Example

HTML <div> class :

The HTML Division element (<div>) is the generic container for flow content. It has no effect on the content or layout until styled using CSS.

The <div> tag is nothing more than a container unit that encapsulates other page elements and divides the HTML document into sections. Web developers use <div> elements to group together HTML elements and apply CSS styles to many elements at once.

Division Example 1:

Division Example 2:


Output:


We use the <div> tag to group two paragraphs for applying a background to the text, and to add color to this word we place it within <span> tag.

Pay attention, that the <div> tag is a block-level element, so a line break is placed before and after it.


Division Example 3:


Output: