How To Remove Space Above Header In WordPress

white space

If you are working on a WordPress theme and notice an annoying white space that appears at the top of your pages, it is most likely due to the admin menu.  If you inspect the page using the Developer Console in your browser by pressing F12, when you highlight the html tag you will see the following css is being applied:

html {
    margin-top: 32px !important;
}

To “neutralize” this extra space, add the following code to your style.css file.  You may need to adjust it slightly depending on your theme but this should remove the annoying extra space at the top of your pages.

/* Remove whitespace from top */
html {
    margin-top: -22px !important;
}

 

Sidebar
How To Remove Space Above Header In WordPressHow To Create A Simple WordPress Theme From ScratchHow To Add Class Depending On Media Screen SizeHow To Disable Post Revisions In WordPressAdd An Edit Link to WordPress Posts