960 Grid System and Full Width Backgrounds

Created on August 06, 2010 by Garrett Winder

Out of the box, the 960 Grid System can accomplish just about any complex website layout you can imagine. There are times, though, when you're going to have to do some minor customizing to cleanly accomplish what you want.

For example, lets pretend we want to have a full width background for our header and footer. We'll need to make some sort of wrapper to go around the grid like this:

.whole {
 width: 100%;
}

.branding {
 background: url("tile_branding.png") repeat;
}

With these new classes in place we can build a workable (but bloated) solution that would look something like this:

<div class="whole branding">
 <div class="container">
  <header class="grid_12">
   <!-- blah blah blah I'm a header -->
  </header>
  <span class="clear"></span>
 </div>
</div>

<div class="container">
 <div class="grid_12">
  <!-- Page content goes here -->
 </div>
 <span class="clear"></span>
</div>

<div class="whole branding">
 <div class="container">
  <footer class="grid_12">
   <!-- And finally, the foot. -->
  </footer>
  <span class="clear"></span>
 </div>
</div>

The above lazy approach isn't too bad, but we can do better. I'd be a lot more satisfied without those pointless .container divs wrapping the header and footer. Let's make some adjustments to the css:

.whole {
 ...
}

.branding {
 ...
}

.whole header,
.whole footer {
 margin: 0 auto;
 width: 940px;
}

Now in our HTML we can drop the .container wrappers around our header/footer as well as drop our header/footer classes.

<div class="whole branding">
  <header>
   <!-- blah blah blah I'm a header -->
  </header>
  <span class="clear"></span>
</div>

<div class="container">
 <div class="grid_12">
  <!-- Page content goes here -->
 </div>
 <span class="clear"></span>
</div>

<div class="whole branding">
  <footer>
   <!-- And finally, the foot. -->
  </footer>
  <span class="clear"></span>
</div>

Tada! A clean, simple approach to full width backgrounds using the 960 Grid System. Enjoy.

Like what you see here? Share the love!

If you liked this article, feel free to share it. We won't stop you.

You can also stay up to date by follow us on or subscribing to our newsletter.

Comments

Learn how to clear your floats. <span class="clear"></span> is no good.

- by Troll on Sep 28, 2010 at 5:51 PM

I agree, but it's part of the core 960 code, which is exactly what this article is about.
- by on Sep 29, 2010 at 3:09 AM

Not possible to use <div class="clear"></div> instead?
- by Michael Pehl on Oct 19, 2010 at 3:35 PM

Yes you can do that. Span is just cleaner when styles are disabled.
- by on Oct 19, 2010 at 3:40 PM