A few weeks ago I found in Internet two beautiful posts to footer stick – lucky accident considering the huge information in the web. And lucky me, if you can imagine how long I’ve been trying to find out how to avoid using tables for layout. Even if it is only to stick the footer on bottom of the page.
Stop using tables!
Except for table-data of course
In the web you can find several ways to stick the footer without table (with height 100%). Some of them are based on JavaScript and often they are quite complicate. Others used long and messy hacks or a lot of extra HTML markup and the solution is confusing.
Now I want to say ‘Thank you for the really simple and working methods!’ to Bobby van der Sluis and to Ryan Fait.
At first I thought that these methods work only in XHTML, but today I tested both solutions in different doctypes and they …
Work fine in (X)HTML and IE6, IE7, FF, Opera, Safari & Chrome
Here is the list of doctypes tested in Internet Explorer 6, Internet Explorer 7, Mozilla Firefox 3.0.6, Opera, Safari for Mac and Google Chrome:
- HTML 4.01 Transitional
- HTML 4.01 Strict
- HTML 4.01 Frameset
- XHTML 1.0 Transitional
- XHTML 1.0 Strict
- XHTML 1.0 Frameset
- XHTML 1.1
Resource 1: A List Apart
Bobby van der Sluis has described the problem with the footer since 2004. In his article Exploring Footers he represents the JavaScript solution because of IE5 bug.
Although, his simple CSS method works in IE and FF, so here is the code:
html, body { height:100%; }
#container { position:relative; min-height:100%; }
#footer { position:absolute; bottom:0; }
<div id="container">
<div id="content">...</div>
<div id="footer">...</div>
</div>
Resource 2: Las Vegas Web Design
The second nice post on this topic is Make the Footer Stick to the Bottom of a Page by Ryan Fait. It is really short and understandable resource. Here I have to mention that some times in Internet Explorer there is a little bug – it is possible to appear vertical scrollbar when you resize the browser’s window.
Here is the code:
* { margin:0; }
html,body { height:100%; }
.wrapper { min-height:100%; height:auto!important; height:100%; margin:0 auto -4em; }
.footer,
.push { height: 4em; }
<div class="wrapper">
<p>Your website content here.</p>
<div class="push"></div>
</div>
<div class="footer">
<p>Copyright (c) 2008</p>
</div>
Floating content problem
Maybe it will be a problem using floating elements in the main content (before footer). So you can check for more information the site www.cssstickyfooter.com and the post with many comments A CSS Sticky Footer that Works in 2009 (Chrome too) – both by Steve Hatcher.
In my next web project I’ll test that and post here.
Updates
2009-09-28: I’ve just added new post with my own solution for XHTML http://blog.aip-solutions.com/311/footer-stick-on-bottom-2/
wow … at the end … every confused server-side programmer like me will be able to make a footer … now I feel happy
Comment by Peter Mihailov — 25/02/2009 @ 20:15
really helpful information…
Comment by martin — 26/02/2009 @ 08:47
indeed very useful work-arround for IE6 CSS properties:
min-width:100px; /*IE6 do not understand min width and ignores it*/; width:200px; /* OK for all browsers*/ width:auto!important; /* OK for modern browsers; IE6 ignores it*/At the end for IE6 the computed style is:
width:200px;and for the rest:min-width:100px;should be true for all CSS properties.would be nice to know how these solutions will work on IE7, Safari on mac and Chrome
Comment by Peter Assenov — 26/02/2009 @ 08:55
@Peter Assenov: Thanks for the comment. I tested the two methods on IE7, Opera, Safari for Mac and Chrome – they seems to work fine. As I promised, I’ll test them in my next web project with real content and floating elements.
Comment by mili — 27/02/2009 @ 16:20
PillSpot.org. Canadian Health&Care.Special Internet Prices(up to 40% off average US price).No prescription online pharmacy.Pillspot.org. Vitamins@buy.online” rel=”nofollow”>.…
Categories: Mental Health/Epilepsy.Stop SmokingMens Health.Blood Pressure/Heart.Womens Health.Pain Relief.Anti-allergic/Asthma.Skin Care.Antidiabetic.Cholesterol.Antibiotics.General Health.Vitamins/Herbal Supplements.Weight Loss.Anxiety/Sleep Aid….
Trackback by FREDERICK — 25/06/2010 @ 14:24
Pillspot.org. Canadian Health&Care.Special Internet Prices.No prescription online pharmacy.PillSpot.org. Herbal-supplements@buy.online” rel=”nofollow”>.…
Categories: Womens Health.Anti-allergic/Asthma.Blood Pressure/Heart.Vitamins/Herbal Supplements.Stop SmokingMens Health.Anxiety/Sleep Aid.Stomach.Mental HealthWeight Loss.Pain Relief.Antidiabetic.Antidepressants.Skin Care.Eye Care.Antibiotics.Anti…
Trackback by KENNY — 25/06/2010 @ 22:44
Emblem http://copious-systems.com/tag/Emblem : Dragons And The Blade Of Light Shadow DS/…
Emblem…
Trackback by Dragons And The Blade Of Light Shadow DS/ — 29/08/2010 @ 09:32
light http://zhunterf5-we.ABABYCLOTHES.INFO/tag/Wiring Diagram part light/ : Wiring…
Diagram…
Trackback by Diagram — 29/08/2010 @ 12:20
stereo http://ktips7a0cm.AACEHARDWARE.INFO/tag/car+stereo+zune+Converter/ : zune…
zune…
Trackback by stereo — 29/08/2010 @ 12:31
2 http://xtwolz8m.02JEEPPARTS.US/tag/2+Corn+Used/ : Corn…
2…
Trackback by 2 — 29/08/2010 @ 12:54
skins http://dmixer6vxt.AUTOPARTSTHAI.INFO/tag/skins+Lyrics+mixer/ : skins…
Lyrics…
Trackback by mixer — 29/08/2010 @ 23:10
depot http://jrealtreebqyg.AUTOSECTIONS.INFO/tag/home+depot+freezer+door/ : depot…
freezer…
Trackback by freezer — 29/08/2010 @ 23:15
ADSL http://ualiceozih.ACEHARDWAREE.INFO/tag/Rosso+lip+ADSL/ : ADSL…
lip…
Trackback by lip — 29/08/2010 @ 23:18
O’Connor’s http://ys450qov5v.AACEHARDWARE.INFO/tag/O‘Connor’s+Santa+Grill/ : Santa…
O’Connor’s…
Trackback by Grill — 29/08/2010 @ 23:23
Beds http://wpineuftw548.05KIAPARTS.US/tag/Log+Beds+bed/ : Log…
Log…
Trackback by Log — 29/08/2010 @ 23:34
peach http://xversacep8qg9c.AUTOTECHGUIDE.INFO/tag/Republic+Of+Tea+Ginger+Peach+ginger+peach/ : Republic…
Ginger…
Trackback by ginger — 29/08/2010 @ 23:40
back http://ybackma5r.APTAUTOPARTS.INFO/tag/Book+Basics+back/ : Book…
back…
Trackback by Basics — 30/08/2010 @ 04:12