Horje
How to crearte The <div> Element in HTML

The <div> element is often used as a container for other HTML elements.

The <div> element has no required attributes, but style, class and id are common.

When used together with CSS, the <div> element can be used to style blocks of content:


Basic Example of The <div> Element in HTML

When used together with CSS, the <div> element can be used to style blocks of content:
 <div style="background-color:black;color:white;padding:20px;">
  <h2>London</h2>
  <p>London is the capital city of England. It is the most populous city in the United Kingdom, with a metropolitan area of over 13 million inhabitants.</p>
</div> 

Full Example of The <div> Element in HTML

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<div style="background-color:black;color:white;padding:20px;">
  <h2>London</h2>
  <p>London is the capital city of England. It is the most populous city in the United Kingdom, with a metropolitan area of over 13 million inhabitants.</p>
  <p>Standing on the River Thames, London has been a major settlement for two millennia, its history going back to its founding by the Romans, who named it Londinium.</p>
</div> 

</body>
</html>

Output should be:

Full Example  of The <div> Element in HTML





Related Articles
What is HTML Block and Inline Elements HTML Block and Inline Elements
How to create HTML Block-level Elements HTML Block and Inline Elements
How to create HTML Inline Elements HTML Block and Inline Elements
How to crearte The <div> Element in HTML HTML Block and Inline Elements
How to create The <span> Element in HTML HTML Block and Inline Elements

Single Articles
Basic Example of The <div> Element in HTMLHTML Block and Inline Elements
Full Example of The <div> Element in HTMLHTML Block and Inline Elements

Read Full:
HTML Block and Inline Elements
Category:
Web Tutorial
Sub Category:
HTML Block and Inline Elements
Uploaded by:
Admin
Views:
126


Reffered: https://www.w3schools.com/html/tryit.asp?filename=tryhtml_div