Support » Fixing WordPress » 3.1 Update Causing 28px top-spacing in html body

  • Resolved looknostyle


    After updating my wordpress it started cause some unusual body spacing. When I view page source I see some unusual coding, trouble is I dont know which file it’s located in to delete it:

    <style type=”text/css” media=”print”>#wpadminbar { display:none; }</style>
    <style type=”text/css”>
    html { margin-top: 28px !important; }
    * html body { margin-top: 28px !important; }

    There’s the css that shouldn’t be in the index but I dont know how it got there or how to get rid of it. It’s magically appeared after the update, any suggestions?

Viewing 15 replies - 1 through 15 (of 27 total)
  • @looknostyle, that would be the new admin bar for wp 3.1

    If it’s acting up on your site, open your user profile (Users > Your Profile) and uncheck the ‘Show on Front’ option to make it disappear.


    thanks you!

    I’ve unchecked that option but am still getting the 28px margin at the top of my site. Weird!

    The Disable Admin Bar plugin’s not doing it for me either. Double weird.

    Try adding this to your theme’s functions.php. This fixed the issue on my site:

    function my_function_admin_bar(){ return false; }
    add_filter( 'show_admin_bar' , 'my_function_admin_bar');

    Essentially it overrides the hook to show_admin_bar with a custom function, which returns false, and as a result remove the admin bar altogether.

    Not sure if you’re after such an extreme solution but it worked for me. I didn’t need the admin bar anyway anyway as most of my site functions are already taken care of within my Firefox bookmarks.

    Good luck!

    Thanks @mobilephonefinder. That worked!

    This top-margin error was only affecting Firefox 3.6 on Windows. IE8 (Windows), FF (Mac), and Safari (Mac) rendered correctly. I added the function listed above and it corrected the problem. Thanks!

    Thanx a lot 🙂

    So how do you eliminate the spacing but keep the admin bar? I went into the admin-bar.php file and removed the !important style, but the spacing still showed up when not logged in.

    This is the worst element of this whole thing. It shouldn’t be so hard to butt your header up against the top of the viewport.

    Moderator Ipstenu (Mika Epstein)


    🏳️‍🌈 Plugin Review Team Rep

    First up, no one ever edit core, please 😉 Also posting in resolved topics makes it hard for us to know you need help. We assume if it’s resolved, you’re done.

    If your site is munging the admin bar layout, check that you have BOTH wp_head() and wp_footer() in your theme. You need both 😀

    If that doesn’t help, you can put this in your functions.php:

    function my_admin_css() {
            if ( is_user_logged_in() ) {
            <style type="text/css">
            <?php }
    add_action('wp_head', 'my_admin_css');

    If you want to change it for non-logged in users, it’s !is_user_logged_in

    Sorry. Didn’t realize it was closed. I have been (with great frustration) trying to find the 28px for an hour, then I couldn’t log into WP to look into it since the passwords were changed and the reset password still wasn’t letting me in.

    wp_header() and wp_footer() are there, since it’s still twenty eleven. I’ll look into your suggestion; however right now I’m going with, “If you can’t beat them, join them,” and working the gap into the design.

    Thanks MobilePhoneFinder 🙂

    That did the trick for me


    Ipstenu,the function is very good yet!

    Khaled Hakim


    Just wanted to confirm that the solution provided above fixed my issue. Note that the issue was browser-dependent. On chrome I had no issues at all while on firefox the margin problem was driving me nuts.

    Opened the functions.php file found in wp-content/themes/twentyten… added the following code tot he bottom of the file:

    function my_function_admin_bar(){ return false; }
    add_filter( 'show_admin_bar' , 'my_function_admin_bar');

    Margin issue resolved pour moi.


    Just for everyone’s information, I was having some of the symptoms mentioned above (margin and such), but I was also having a LOT of Javascript errors.

    As our Half-Elf Support Rogue mentioned, YOUR THEME ABSOLUTELY HAS TO HAVE wp_head() and wp_footer(), or you will get admin bar, margin, and javascript errors everywhere.

    I downloaded a cheap theme which didn’t properly do this. When I added my head and foot, all was good!

    The “display admin bar” settings don’t really matter, as they will function correctly with a correct head and foot.

Viewing 15 replies - 1 through 15 (of 27 total)
  • The topic ‘3.1 Update Causing 28px top-spacing in html body’ is closed to new replies.