Here are two methods that I have used to make a website’s sidebar extend for the entire length of it’s container.
Typically, a sidebar <div> ends once it reaches the end of the content inside it, which becomes an issue when the main content of the page is longer than the content in the sidebar.
Example #1: Sidebar background is same color as container background
For this solution, we must use four <div> tags: one which will contain the sidebar, the main content, and a footer. The footer doesn’t need to contain anything if you don’t want it to, it just needs to be there.
First, set up your html page like this:
<div id="container"> <div class="sidebar"></div> <div class="content"></div> <div id="footer"></div> </div>
And add your content to the page.
Next, we will style the four different elements we are using. Add these codes to your stylesheet (edit them as necessary):
#container {
width: 100%;
background: #FFFAF0;
}
.content {
width: 950px;
float: right;
padding: 10px;
background: #FFFAF0;
}
.sidebar {
width: 220px;
float: left;
padding: 5px;
background: #FFFAF0;
}
#footer {
clear:both;
background:#FFFAF0;
}
There are two important points to this solution. One is the footer property “clear:both.” If you don’t have the footer (or another div) that contains the “clear:both” property at the bottom of the container, the footer will appear at the bottom of the sidebar, but not necessarily at the bottom of the content, like this:
By using the “clear:both” property, the footer sticks to the bottom of the sidebar and the content. As I said earlier, you don’t have to put anything inside the footer if you don’t want to, but it needs to be there.
The other key element in this solution is that the background of the sidebar is the same color or image as the background of the container. This is because we are not actually extending the sidebar. The sidebar still ends after it reaches the end of its content, but it will appear that the sidebar continues to the end of the container’s content as long as it’s background is the same as the container’s background – which does continue to the bottom.
For instance, let’s say that you changed your stylesheet so that the background of the sidebar was different than the background of the container.
But, if you make sure that the background color of the sidebar is the same as the background color of the container, it will look like this:
Example #2: Sidebar background is different than the container background
Now, let’s say that you want the color of the sidebar to be different than the color of the container, like this:
This is possible by adding another <div> to your page.
First, add the styles for the new div your stylesheet:
#newcontent {
width:100%;
background:#969696;
}
Make sure the background of this new div is the same as the background of the sidebar.
Now, set up your web page like this:
<div id="container"> <div id="newcontent"> <div class="sidebar"></div> <div class="content"></div> <div id="footer"></div> </div> </div>
This new div now fills in the “space” at the bottom of the sidebar so, as long as it has the same background as the sidebar has, it will appear for all intents and purposes that your sidebar is actually extending to the bottom of the container.
I hope these examples have helped to solve your sidebar issues, but be sure to let me know if neither of these solutions work for you or if you have any questions or trouble at all and I would be happy to try and help you come up with a solution.







A 2 minute solution! Thanks a lot!
Turns out that I was going about the whole thing in a kind of roundabout way. Thanks again Libby for your help.
Thanks for the feedback Gabi, glad this post helped!
I remember how frustrated I used to get with this when I was creating my own WordPress tempates. Great tutorial!
Hi Tia,
Yes, this seems to be a very common issue judging by the fact that this has been the most popular post on my blog for months! I initially wrote the post to have as a reference for myself if and when I ever ran into the sidebar issue again, I never imagined it would be such a hit but I am glad that it is if it helps other people solve their sidebar issues.
Thank you for this tips in extending sidebar on wordpress. This is helpful to me especially that I am not good at coding because I don’t have computer programming knowledge but I am very interested to learn more.
Hey Libzter, I want that sweet follow me bubble you have here to the right on my site but havent implemented or designed my site with wordpress Can you help
by the way thanks for your help with the sidebars it ended up being so simple
Hi!
Thanks for commenting. Here is an article that talks about adding a Twitter Follow Me button to your website – http://www.computingunleashed.com/easily-add-floating-twitter-follow-meus.html. Please let me know if that works for you or not or if you have any questions.
I am really glad to hear that this post helped you with your sidebars!
I am having troubles getting my sidebar images to repeat all the way down ( http://ozarkhmongfilm.com/index.php?p=about ) is a good example.
My CSS:
body,td,th {
font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif;
color: #FFFFFF;
background-color: #4b3f6d;
margin: 0;
padding: 0;
height: 100%;
}
#content {margin-left:10%; margin-right:10%; background-color:4b3f6d; height: 100%;}
#footer {
clear:both;
background:#000000;
}
a:link {
color: #FF0;
}
a:visited {
color: #0F0;
}
a:hover {
color: #0FF;
}
a:active {
color: #0FF;
}
#sidebar1 {
background-image:url(images/sidebar-left-b.gif);
background-repeat:repeat-y;
background-position:right;
left:0;
float: left;
height: 100%;
z-index:-1;
overflow:visible;
}
#sidebar2 {
background-image:url(images/sidebar-right-b.gif);
background-repeat:repeat-y;
background-position: left;
right:0;
float: right;
height: 100%;
z-index:-1;
}
#content {
width: 80%;
z-index:2;
height: 100%;
}
div.panls {width:20%;position:absolute; top:0;}
And viewing the source should show my div setups… no doubt my mistake can be seen in the CSS.
Any help is much appreciated! I’m pulling my hair out!
Hi Steve,
Sorry for not getting back to you sooner. I am looking into the issue right now and I’ll email you when I figure out what the problem is.
Thanks for commenting, talk to you soon!
~Libby
I appreciate any help in advance. I went over the code, and noticed I had two #content sections. I’ve also tried a container with a footer, and just don’t believe I am implementing the ideas correctly. And of course, I am trying to implement all this using a 3-column fluid design with those side images doing what they do…
Anyway, again, I would appreciate any help! Excellent tips here for sure.
Libby – you are a web goddess and helped me fix my sidebar that has been giving me fits for the past 3 days. Thank you!
Haha, thanks Julia! I am glad to hear that!
Hi Fisher,
Im a beginner in WP and m so glad to know about this sidebar extension , this post is very useful for a newbie like me.. Glad to see the comments over this , learned a lot from these..
Regards
Navya.
Thank you! However, the new code pushes the bg image of the container all over the place. What’s happening is truly weird (that’s CSS, I guess). In Safari, the sidebar extends all of the way to the end of the page and, just for fun, doubles the length of the content area, leaving a nice, big blank space. In Firefox and IE, the sidebar goes almost all the way down to the bottom of the page, but stops about 30 pixels short of the footer. That seems to have something to do with the length of the content. I’m using a Dreamweaver CS5 template that I really haven’t altered, except for the custom widths (carefully measured) and my own background images and colors. I don’t have a clue where to turn for help. This has been the only page I’ve found that might do. Thank you!
If it helps, the test URL is at http://www.trsgraphics.com/dmc/index.html
Hi Thomas,
I see what you are saying when I look at your test site. Did you follow the steps for example 2 in the post above? I think if you added another div with the background color #330A12, it would fill in that space at the bottom of your sidebar.
Feel free to email me the FTP login information for your site if you’d like me to add the new div for you. My email address is libby@thelibzter.com. Please let me know if that helps or not. Thanks!
Thank you! A simple solution, adding the div, thanks for sharing.
Thank you!!! you help me very much with this!
Glad to hear it, thanks for letting me know!
I guess I do not even know which page of my theme to apply this technique to. On my index, the get footer and get sidebar isn’t even in a div tag to begin with. It’s a generic wordpress theme. Anyway you can hint at which php file to use this? Is it .index, or sidebar or which .php LOL ? Pardon my lack of know how.
Hi Holly,
You will want to open the sidebar.php file of your theme. That is where you will see and be able to edit the div tags, etc. Please let me know if you need any more help or have other questions. Thanks!
~Libby
You don’t know how much I love you for this! I’ve been looking for a solution to this sidebar problem for ages, and I finally found one that actually works! Thank you so much!
Thanks for letting me know Angie!
Hello there,
Everyone wants to make the sidebar longer. I actually want to cut the side bar off the beginning so my slider can be wider. In essence, have the left side bar start at a lower level. Is that possible?
http://www.nexteditiononline.dom
Hi Emmanuel,
I would add a “margin-top” style to “.sidebar-left” in your stylesheet – can you try that and let me know if it works?
Thanks!