Posted on 1 Comment

CSS : Stretch sidebar full height of the page

One of the first things I needed to figure out is how to have the sidebar colour or pattern stretch to line up with the length of the content. I’ve found the best way to do this is to initially create a background image showing a segment of the width of your site like this:
(This image would repeat vertically, with the white bit as my content area and the coloured bit on the right as my sidebar)

Then set up your sidebar and content area within the y-axis repeating background div. This way, the content will stretch down and cause the background to repeat, forcing the sidebar colour to also extend.

See below for a quick code example:

First, the CSS to show the bg image and the content areas:

#full_content {
margin: 0 auto;
width: 708px;

#side_bar {
width: 210px;

#main_area {
margin: 10px auto;
width: 670px;

Now the div’s to organise your content

<div class=”full_content”>

<div class=”side_bar”>
Sidebar content in here

<div class=”main_area”>
Main area text


1 thought on “CSS : Stretch sidebar full height of the page

  1. Thank you! I tried some of the other hacks out there (the padding/margin overflow one, various positioning models, etc), but yours gave me exactly what I wanted while preserving my layout’s simplicity.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.