First things first

Obviously you can't just launch straight into paragraphs of text right at the top of your page, or your users won't know where they are and will be unlikely to read on. Normally the first things on your page will be a logo image which links back to the homepage, followed by your main navigation, and possibly some interactive elements such as search or login forms.

For your site to be accessible you should also include a "Skip Navigation" link, to allow users with screen-readers to skip straight to the main content.

These initial elements allow the user to establish what site they are on, and to quickly see the main sections they can navigate to. Immediately after these elements, you should place your main content section, and only after that, any additional content which is of less importance, such as secondary navigation, extra links, buttons, ads etc.

Content order can be independent of page layout

Using CSS floats, it's actually possible to achieve (almost) any layout you can think of. As shown in the following examples, two pages with the exact same HTML markup (except for a necessary extra div in the last one) can be displayed in completely different layouts by the clever use of CSS styles.

The HTML markup

<div class="example-layout">
	<div class="example-header">
	    Page Header
	</div>
	<div class="example-content">
		<div class="primary">
			Primary Content
		</div>
		<div class="secondary">
			Secondary Content
		</div>
		<div class="tertiary">
			Tertiary Content
		</div>
	</div>
	<div class="example-footer">
		Page footer
	</div>
</div>
			

I've defined some common styles so you can easily see the placement of the content:

  .example-layout {width: 80%; margin-left: 10%;}
  .example-header, .example-footer {border: 1px solid #999;}
  .example-footer {clear: both;}
  .primary {background: #FBA95E; height: 6ex;}
  .secondary {background: #FFE08F;}
  .tertiary {background: #FFFABF;}
  .example-header,
  .example-footer, 
  .primary, 
  .secondary, 
  .tertiary {padding: 10px 2%; margin: 5px 0;}
  .example-content {padding: 0; overflow: hidden;}
  .primary, .secondary, .tertiary {margin-top: 0;}

Note that each content div has 2% padding on the left and right. This will need to be taken into account when working out column widths.

Single column

This is the easiest way to keep your main content near the top of the page, simply let the additional content stack beneath it. No floating required, the order your content appears in the HTML is the order it will appear on the page.

Page Header
Primary Content
Secondary Content
Tertiary Content

Two columns

You can easily position your main content to the left or right of the secondary content by using floats:

Main content on the left

  .two-left .primary {float: left; width: 60%; margin-right: 2%;}
  .two-left .secondary {float: right; width: 30%;} 
    /* 60% + 30% + 2% + 8% padding = 100% */
  .two-left .tertiary {clear: both; width: 100%;}
Page Header
Primary Content
Secondary Content
Tertiary Content

Main content on the right

  .two-right .primary {float: right; width: 60%; margin-left: 2%;}
  .two-right .secondary {float: left; width: 30%;} 
    /* 60% + 30% + 2% + 8% padding = 100% */
  .two-right .tertiary {clear: both; width: 100%;}
Page Header
Primary Content
Secondary Content
Tertiary Content

Three Columns

Main content on the left

  .three-left .primary {float: left; width: 40%; margin-right: 2%;}
  .three-left .secondary {float: left; width: 22%; margin-right: 2%;}
  .three-left .tertiary {float: left; width: 22%;}
    /* 40% + 44% + 4% + 12% padding = 100% */
Page Header
Primary Content
Secondary Content
Tertiary Content

Main content on the right

  .three-right .primary {float: right; width: 40%; margin-left: 2%;}
  .three-right .secondary {float: right; width: 22%; margin-left: 2%;}
  .three-right .tertiary {float: right; width: 22%;}
    /* 40% + 44% + 4% + 12% padding = 100% */
Page Header
Primary Content
Secondary Content
Tertiary Content

Main content in the centre

Note: This layout requires an extra div (class="wrap") to be placed around the primary and secondary content and floated left, in order for the primary content to be floated right within it.

<div class="example-layout">
	<div class="example-header">
		Page Header
	</div>
	<div class="example-content">
		<div class="wrap">
			<div class="primary">
				Primary Content
			</div>
			<div class="secondary">
				Secondary Content
			</div>
		</div>	
		<div class="tertiary">
			Tertiary Content
		</div>
	</div>
	<div class="example-footer">
		Page footer
	</div>
</div>
  .three-middle .wrap {float: left; width: 70%; margin-right: 2%;}
  .three-middle .primary {float: right; width: 58%; margin-left: 2%;}
  * html .three-middle .primary {width: 57%; margin-left: 1%;} 
    /* solves percentages issue in IE6 */
  .three-middle .secondary {float: left; width: 32%;}
  .three-middle .tertiary {float: right; width: 24%;} 
    /* 70% + 2% + 24% + 4% padding = 100% */
Page Header
Primary Content
Secondary Content
Tertiary Content

Note: You may run into problems if any of your column divs have left or right borders, as they will be included in the overall width of the layout. If your layout has a fixed width in pixels, you will be able to work out the widths including borders, but if you're using percentages as in this example, you're better off without borders, or you may just have to take of half a percent from the margins to accomodate the borders. A little experimentation will pay off.

Do you love our approach to crafting simple & effective web sites that just work for people?

We'd love to hear about your web strategy. Contact one of our team today!

Search this site
Pro Tips
Learn how to make fantastic web site designs..
Buy "Save the Pixel" now!
On “Save the Pixel”
Clicss templates, great robust useful CSS templates from £40
Share this Article
Send to a friend now&hellip
Follow Ben Hunt on Twitter
Floor 3
111 Buckingham Palace Road
London
SW1W 0WQ
UK
Phone
+44 (0)207 1600 989

Articles + tutorials in HTML & CSS Production

Overview
Menu of all our articles on HTML, CSS and web page production
CSS
List of our CSS articles
Introduction to CSS
Beginner's introduction to Cascading Style Sheets (CSS)
HTML
List of HTML articles
Introduction to HTML
Introduction to basic HTML tags and the structure of HTML documents.
How HTML, CSS and JavaScript work together in making web pages
Best practice for using HTML, Cascading Style Sheets, and JavaScript together to make web pages.
Building a web page with HTML + CSS for complete beginners
Learn what HTML is and how to build a website from scratch. A guide to creating a web page using HTML and CSS for people with no prior knowledge
Block vs Inline display style in CSS
HTML elements can be displayed either in block or inline style. The difference between these is one of the most basic things you need to know in order to use CSS effectively.
Inheritance and Cascading Styles in CSS
Introduction to how styles apply in CSS through inheritance and cascading.
HTML Lists
The basics of lists: unordered, ordered and definition lists covered.
HTML Tables
The basics of tables. When to use tables, and how to do it. Includes tips on colspan and rowspan properties, and the col and colgroup tags.
Anatomy of HTML tags
Describes the common attributes that can feature in your HTML tags.
Introduction to Semantic HTML
Explains what semantic HTML, or semantically-correct HTML, is and how it benefits web development.
Semantic HTML Handbook - Benefits of Writing Semantic HTML (Nov 15 2009)
Free article on Semantic HTML. Why you should learn Semantic HTML. Benefits for SEO and code reuse explained.
Complete List of HTML/xHTML Tags, With Guide to Proper Semantic Use (Nov 15 2009)
My Complete List of HTML/xHTML Tags, With Guide to their Proper Semantic Use
A Few Tips and Tricks to Write Better Semantic HTML (Nov 15 2009)
Tips and tricks for writing better semantic HTML or xHTML from a professional web producer
Web Page Production using xHTML and CSS (ebook)
This new 61-page ebook provides a worked example of web production, taking you through the entire process from a Photoshop page design, to a working HTML page template.
Datasheet-style form using HTML, CSS and JavaScript
Make a datasheet-style web form using HTML, CSS and JavaScript
Tabular list-style form using HTML, CSS and JavaScript
Create an appealing tabular list using HTML, CSS and JavaScript
Complete HTML tag reference
Our complete guide to HTML and xHTML tags, and their proper usage.
Keeping your content in order of priority with flexible CSS layouts
This article shows you how to use CSS floats to achieve any column layout, while keeping your most important content highest on the page.