CSS Footer

This is a technique for creating a CSS footer that will snap to the bottom of the content or the bottom of the page, which ever is lower.  This all without any JavaScript. Download the code here.

I learned the technique through "Google University" [read: I Googled it until I found an answer]. I wish I could give credit, but I've since misplaced the link I used. Thanks to whomever.

The technique involves creating an "everything but the footer" div, and setting it's min-height to 100%. (For IE 6, set height to 100% -- compensate for IE 6's lack of support for min-height, and the fact that it auto-expands divs to fit content). Then you create a "footer" div as a sibling, and set margin-top to the height of the footer. Add a margin-bottom to the "everything else" div that matches, and you've got yourself a footer that stays at the bottom of the page.

Download the sample, and give it a spin. 

There's a bit of JavaScript goodies in there unrelated to the technique as well.  I can't take credit for NoIEActivate.js, but I also can't find it's source either.  It's great for avoiding the "click here to activate" in <object> and <embed> tags in IE, and doesn't require any kind of "create a javascript file to source" garbage that plagues servers.

Rob

posted @ Thursday, December 07, 2006 10:28 AM

Print

Comments on this entry:

# re: CSS Footer

Left by adi at 2/8/2007 5:20 AM
Gravatar
You made my day dude!!! You have no idea how long i was looking to get around that nasty problem ...specially in IE6

Seriously man, you're my hero for 2007 :)

thanks!!!

# re: CSS Footer

Left by Brandon at 5/23/2007 11:58 AM
Gravatar
Are the javascript includes required for this to work? You seem to indicate they're not, but why include them if they're not required. Kind of confusing.

# re: CSS Footer

Left by Brandon at 5/23/2007 12:07 PM
Gravatar
You've got a lot more code in your css sample file than you indicate is needed on the main explanation page. Your sample code is closer to the typical footerStickALT code.

# re: CSS Footer

Left by Author at 6/14/2007 2:50 PM
Gravatar
Brandon,

Yes, the JavaScript is completely irrelevant to the solution at hand. It can safely be ignored.

Rob

# re: CSS Footer

Left by Gergo at 3/1/2010 10:20 AM
Gravatar
Thank you very very much!
I tried many solutions, but this one is working only for my webpage.

Your comment:



 (will not be displayed)


 
 
 
Please add 1 and 8 and type the answer here:
 

Live Comment Preview: