{"id":37576,"date":"2016-07-21T13:01:16","date_gmt":"2016-07-21T07:31:16","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=37576"},"modified":"2017-09-12T12:43:35","modified_gmt":"2017-09-12T07:13:35","slug":"how-to-consistently-push-footer-at-the-bottom-using-css","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/how-to-consistently-push-footer-at-the-bottom-using-css\/","title":{"rendered":"How to consistently push footer at the bottom using CSS?"},"content":{"rendered":"<p>If an HTML page has very less content then the footer is normally seen\u00a0halfway up the page leaving a blank space below it. This can look bad on a large screen. In such a scenario\u00a0web designers are asked to push footers down to the bottom, but at times designers aren&#8217;t able to achieve this as they are unaware about certain CSS tricks.<\/p>\n<p><strong>How to push footer down through CSS?<\/strong><\/p>\n<p>Actually it&#8217;s not so complicated. This is done by using a mix of HTML and CSS.<\/p>\n<p><strong>HTML Structure:<\/strong><\/p>\n<p>[java]<br \/>\n&lt;div id=&quot;wrapper&quot;&gt;<br \/>\n\t&lt;div class=&quot;header&quot;&gt;&lt;\/div&gt;<br \/>\n\t&lt;div class=&quot;main-content&quot;&gt;&lt;\/div&gt;<br \/>\n\t&lt;div class=&quot;footer&quot;&gt;&lt;\/div&gt;<br \/>\n&lt;\/div&gt;<br \/>\n[\/java]<\/p>\n<p>You would only require\u00a0four div structures to achieve this. The first is wrapper which covers\u00a0the entire\u00a0page content. The second wrapper has\u00a0three divs such as\u00a0header, main content and footer. That&#8217;s it, the magic happens for this only by CSS.<\/p>\n<p><strong>CSS:<\/strong><\/p>\n<p>[java]<br \/>\nhtml,<br \/>\nbody {<br \/>\n   margin:0;<br \/>\n   padding:0;<br \/>\n   height:100%;<br \/>\n}<br \/>\n#wrapper {<br \/>\n   min-height:100%;<br \/>\n   position:relative;<br \/>\n}<br \/>\n.header {<br \/>\n   background:#ff0;<br \/>\n   padding:10px;<br \/>\n}<br \/>\n.body {<br \/>\n   padding:10px;<br \/>\n   padding-bottom:60px;   \/* Height of the footer *\/<br \/>\n}<br \/>\n.footer {<br \/>\n   position:absolute;<br \/>\n   bottom:0;<br \/>\n   width:100%;<br \/>\n   height:60px;   \/* Height of the footer *\/<br \/>\n   background:#6cf;<br \/>\n}<br \/>\n[\/java]<\/p>\n<p>And following is the CSS rule for IE 6 and IE 5.5:<\/p>\n<p>[java]<br \/>\n#wrapper{<br \/>\n   height:100%;<br \/>\n}<br \/>\n[\/java]<\/p>\n<p><strong>Below is the example image that what is the default behaviour and what will be the desired effect<\/strong><\/p>\n<p><img decoding=\"async\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/07\/footer-at-bottom.jpg\" alt=\"footer-at-bottom\" \/><\/p>\n<p>It will also work in the same way for\u00a0iPhones, iPods, iPads and other CSS compatible mobile devices.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If an HTML page has very less content then the footer is normally seen\u00a0halfway up the page leaving a blank space below it. This can look bad on a large screen. In such a scenario\u00a0web designers are asked to push footers down to the bottom, but at times designers aren&#8217;t able to achieve this as [&hellip;]<\/p>\n","protected":false},"author":206,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":8},"categories":[3429,1],"tags":[3743,3742,3744,3745,3746],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/37576"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/206"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=37576"}],"version-history":[{"count":2,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/37576\/revisions"}],"predecessor-version":[{"id":51794,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/37576\/revisions\/51794"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=37576"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=37576"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=37576"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}