liveBook · Manning

Div

As explained in Web Design Playground

An HTML element that defines a generic division or container with no inherent semantic meaning or default presentation.

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

How Web Design Playground covers it

How deep it goes
Defines opening and closing tags, browser behavior, styling use, and nesting, while deferring semantic sectioning to other HTML elements.
Examples
Demonstrates text blocks, styled copyright content, nested landing-page bands, and a font-styled personal home-page container.
What you can do after
Apply it via HTML and CSS to group text, replace unsuitable line breaks, and build nested page-layout containers.
How it connects
Connects div with paragraphs, line breaks, spans, CSS, flexbox, and HTML5 sectioning elements such as section and article.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Web Design Playground. The section links point to the parts of the book it draws on.