A div is a plain container for grouping page content into blocks. It has no built-in meaning or formatting, so CSS can give the container its visual design. section 3.6 section 3.7
Two text blocks
<div>First block of text.</div> <div>Second block of text.</div> The opening and closing tags wrap each block. Unlike a paragraph or line break, each div provides a container that can be styled. section 3.6 section 3.7
Use a div when:
- Text needs a container, but no semantic element such as p, section, or article fits. section 3.6
- You want to group content so CSS can control its font, color, size, position, or layout. section 5.35 section 10.24
- You need an outer background band and a centered, maximum-width inner content container. section 10.36 section 10.37
<div style="font-family: Georgia, serif;"> #2
<p> #3
I've been a professional technical writer for more than 25 years.
I have over 90 books to my credit, which have sold more than four
million copies worldwide. I’ve been building websites since 1996, so
have intimate knowledge of HTML, CSS, and web design. My passion
is to write books and articles to pass along that knowledge and to
create tools that help people build awesome web pages.
</p> #3
<p>
That’s my work side, so what about my personal side? That is, what
do I do in my spare time? I’m glad you asked! Here’s a partial (and
alphabetical) list of things and activities that interest me:
</p>
<ul>
<li>Chariot racing</li>
<li>Dog polishing</li>
<li>Duck herding</li>
<li>Extreme ironing</li>
<li>Navel fluff sculpture</li>
<li>Staycationing</li>
</ul>
</div>
This listing shows a div carrying a font stack while paragraphs and a list remain separate elements inside it. section 5.30
