Skip to content

Make a HTML footer stick to the bottom of a page

Way to often it happens that the footer of your website doesn’t stick to the bottom because the content is too short. You can eradicate this issue with a little JavaScript snippet:

$(function() {
    var heightDiff = $(window).height() - $('body').height();
    if (heightDiff > 0) {
        $('#footer').css('margin-top', heightDiff);


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.