Hiding an H1 behind a logo

aeisn

New member
May 6, 2009
715
12
0
What's the best way to hide an h1 tag behind a site logo for SEO purposes? I did google, just got me a few crappy examples.
 


<a id="logo" href=""><h1>Text</h1></a>

#logo h1{
display: none;
}

#logo{
display: block;
width: Xpx;
height: Ypx;
background: url("") no-repeat;
}
 
A better way to do it would be

h1.logo { display: block; text-indent: -9999px; width: Xpx; height: Ypx; background: transparent url("") no-repeat 0 0; }

This way the H1 itself is the actual logo, and you're not actually hiding it per se (since I suspect some search engines notice display: none;)
 
I'm a big fan of this little tactic. I've done a few tests and I think it helps a lot.
 
<a id="logo" href=""><h1>Text</h1></a>

This is actually semantically incorrect and will not validate. A block-level element (h1) can't be placed inside of an inline-level element (a). It's as if you did <span><div></div></span> - this would equally not validate.

This would be better:

Code:
<h1><a href="#">text</a></h1>

and

Code:
h1 a { width:x; height:y; display:block; text-indent:-9999px; background:url(image.jpg) no-repeat; }

I second the text-indent method Kblessinggr mentions - it validates perfectly and it is not known to be devalued or flagged or whatever by SEs.
 
^^^ I was just gonna say that. h1's must go on the outside of a's, since h1 is a block level element (which means it by default will have a line-break, unlike a's which just flow wherever they fall)
 
Doesn't this apply to display: none as well?
Sure it does. And it looks a lot more fishy when you try to cloak your CSS than when you cloak your links.

It's not like we're hiding anything notorious. A single H1 isn't going to put you out of business.

Google's webmaster guidelines are a lot of bullshit that keep SEOs busy trying to comply to imaginary and arbitrary standards. Like the myth about duplicate content, CSS is fine to abuse right now. If you're doing anything particularly nefarious, you are going to get screwed on a manual review anyway.