Display: The <div> Element

The <div> element is a block-level element that is often used as a container for other HTML elements. The <div> element has no required attributes, but style and class are commonly used. When combined with CSS, the <div> element can style blocks of content:

HTML file: Displayed by browser:
<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>

London

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.

I like this! I could use this. I remember learning it before, but somehow, this idea just never sank into my thick skull!

Back button Table of Contents Next button