1. Computing

How to Build a 3-Column Layout in CSS

By , About.com Guide

4 of 9

Use a Headline Tag for the Header

How you decide to style the header row depends a lot upon what is in it. If your header row is just going to have a logo graphic and headline, then using a headline tag <h1> makes more sense than using a <div>. You can style your headline the same way you would style a div, and you avoid extraneous tags and "divitis".

The HTML for my header row goes right at the top of the container and looks like this:

<h1>My Header Row</h1>

Then, to set the styles on it, I added a red border on the bottom, so you could see where it ends, zeroed out the margins and padding, set the width to 100% and the height to 150px:

#container h1 {
 margin: 0;
 padding: 0;
 width: 100%;
 height: 150px;
 float: left;
 border-bottom: #c00 solid 3px;
 }

Don't forget to float this element with the float: left; property. The key to writing CSS layouts is to float everything - even things that are the same width as the container. That way, you always know where the elements will lay on the page.

I used a CSS descendant selector to apply my styles only to H1 elements that are inside the #container element.

  1. About.com
  2. Computing
  3. Web Design / HTML
  4. CSS
  5. CSS Tutorials
  6. How to Build a 3-Column Layout in CSS - Step-by-Step

©2013 About.com. All rights reserved.