The <div> document division element is a block level element that acts as a container, encapsulating content and dividing the document into sections.
- Starts a new line
- Stretches across the width of its container
- Acts as a container for other elements
CSS is generally applied to provide styling to a <div>, enabling all elements contained with the div to be styled at the same time.
Divs can be nested, and also as an example styled with CSS to say perform width adjustments or apply a specific font.
<!DOCTYPE html> <html> <head> <title>My Document Title</title> </head> <body> <h1>My first Heading</h1> <p>Paragraph one</p> <div style="border:5px solid blue;"> Paragraph two </div> <p>Paragraph three</p> </body> </html>
Save & refresh browser:
My first Heading