HTML Div Element
The <div> element is used as a container for other HTML elements.
The <div> Element
The <div> element is by default a block element, meaning that it takes all available width, and comes with line breaks before and after.
Example
A <div> element takes up all available width:
Lorem Ipsum <div>I am a div</div> dolor sit amet.Result
Lorem Ipsum
dolor sit amet.
The <div> element has no required attributes, but style, class and id are common.
<div> as a container
The <div> element is often used to group sections of a web page together.
Example
A <div> element with HTML elements:
<div>
<h2>London</h2>
<p>London is the capital city of England.</p>
<p>London has over 9 million inhabitants.</p>
</div>Leave a comment
Your email address will not be published. Required fields are marked *