Banded content divides a page into horizontal strips. Each strip can carry a background across the browser window while keeping its text and images in a narrower, centered area. That matters when a full-width paragraph makes readers work harder than they should. section 10.5
Build each band with two nested div elements:
- Style the outer div with the band’s full-width background color or image. section 10.5
- Put the content in an inner div, give it a maximum width, and center it horizontally. section 10.5
A landing page, one strip at a time
A product page can use separate bands for its header, description, testimonials, and purchase options. The description stays readable instead of stretching from one edge of the window to the other; the bands’ backgrounds still fill the available width. section 10.1 section 10.5
<div class="header">
<div class="container"> #1
... #1
</div> #1
</div>
...
<div class="description">
<div class="container"> #1
... #1
</div> #1
</div>
Notice the repeated pattern: each outer band contains a div with the container class. section 10.5
.container { #1
max-width: 800px; #1
margin: 0 auto; #1
clear: both; #1
}
.container::after { #2
content: ""; #2
display: block; #2
clear: both; #2
}
The container’s maximum width limits line length, while its automatic side margins center it. The remaining rules handle floated content inside the container. section 10.5
