CSS: 3 Columns Page Layout Tutorial

By Xah Lee. Date: . Last updated: .

Here's how to create a 3-columns layout using CSS.

CSS 3 columns layout
CSS 3 columns layout. (see raw HTML rendered example)

Create 3 div tags, and set each's width.

Here's the HTML code:

<div id="main">…</div>
<div id="panel-left" class="mypanel">…</div>
<div id="panel-right" class="mypanel">…</div>

Here's CSS code:

#main {

#panel-left {

#panel-right {right:0;

div.mypanel {

For the main container, specify margin-left and margin-right. This will fix the main panel into a narrow central column.

For the left panel, specify a width that is the same as the main's margin-left, and, specify position:absolute; left:0. This will fix the panel on the left side with a fixed width. Similar for the right pane.

You can also add margin:1ex and or padding:1ex. 〔►see CSS Margin vs Padding

Any text that is not in one of the main or panel div container, will be left on the bottom.

Here's a test page you can view source: HTML: Tableless Layout with CSS: test page.

Like what you read? Buy JavaScript in Depth
or, buy a new keyboard, see Keyboard Reviews.