Websynn Internet and Tech Blog


WordPress: html { margin-top: 28px !important; }

If you have WordPress 3.1 and you recently noticed a bar across the top of your site, you might be wondering what this is.

I did a view source on my site, and found these new lines:

<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; }

At first I couldn't tell what program was inserting these, so I downloaded my newly updated site to a local drive, and used Notepad++ to do a file search.

It turns out this is due to the new admin bar in WordPress 3.1, and you can only see it if you are logged in as an admin, your users can't see it. Some people think this is a bug in WordPress 3.1, but it's not.

If you want to get rid of this bar, put this line in your functions.php:

add_filter( 'show_admin_bar', '__return_false' );

You can hide parts of the admin bar with CSS. To remove the comments and the appearance options add this to your stylesheet:

#wp-admin-bar-comments {display:none;}
#wp-admin-bar-appearance {display:none;}

This will help you remove the admin bar in WordPress 3.1 and get rid of that annoying 28px margin!

Filed under: Wordpress Leave a comment
Comments (3) Trackbacks (0)
  1. Thank you very much! I know English badly, I’m from Ukraine. I use translator. I could find the decision of this problem with margin nowhere.
    Thank you!

  2. I thought I messed up something in the code and for an hour looking for a solution. Thank you very much for your help!

  3. The best way I’ve found to remove that white space (it’s not caused by the admin bar) is to search out this css in style.css:

    #page {
    margin: 2em auto;
    max-width: 1000px;

    and switch the 2em to 0em or some variation of the same. That will remove the white space.

Leave a comment

No trackbacks yet.