Martin Zahuta Martin Zahuta - 4 months ago 6
CSS Question

What's the correct way to hide the <h1> tag and not be banned from Google?

The website I am working on uses an image defined in CSS as the main logo. The html code looks like this:

<h1> | The best something ever</h1>

I would like to display just the image defined in CSS and pass the information from the h1 tag to the search enginges only.

What's the correct way to do this? Google is very strict about this, I know that display:none is wrong, what about visibility: hidden ?

Thanks in advance!


You should be fine with visibility: hidden.

That said, if your image is part of the content (and I would dare to say that a company logo is content, not presentation), and you care about accessible html, you should consider changing your code to include the image as a img element with title and alternate text, instead of a css background-image.

Additionally, if you hope to attract search engines to the keywords inside the <h1> element, you might want to include those words more than once in the page. The page title is a much more relevant place than the h1 element, for example.