A logo isn't a primary heading, or even a heading at all, and using the H1 element to markup the logo on each page of your site will do (slightly) more harm than good for your rankings. Semantically, headings (H1 - H6) are appropriate for, well, just that: headings and subheadings for content.
“If you have an image as the page's H1 tag, keep in mind that the H1 is one of the most important clues for a search engine to determine what the page is about, so consider using text instead of an image or at least using descriptive ALT text.”
You're missing the option:
<h1>
<a href="http://stackoverflow.com">
<img src="logo.png" alt="Stack Overflow" />
</a>
</h1>
title in href and img to h1 is very, very important!
I do it mostly like the one above, but for accessibility reasons, I need to support the possibility of images being disabled in the browser. So, rather than indent the text from the link off the page, I cover it by absolutely positioning the
to the full width and height of the <span>
<a>
and using z-index
to place it above the link text in the stacking order.
The price is one empty <span>
, but I'm willing to have it there for something as important as an <h1>
.
<h1 id="logo">
<a href="">Stack Overflow<span></span></a>
</h1>
#logo a {
position:relative;
display:block;
width:[image width];
height:[image height]; }
#logo a span {
display:block;
position:absolute;
width:100%;
height:100%;
background:#ffffff url(image.png) no-repeat left top;
z-index:100; /* Places <span> on top of <a> text */ }
If accessibility reasons is important then use the first variant (when customer want to see image without styles)
<div id="logo">
<a href="">
<img src="logo.png" alt="Stack Overflow" />
</a>
</div>
No need to conform imaginary SEO requirements, because the HTML code above has correct structure and only you should decide does this suitable for you visitors.
Also you can use the variant with less HTML code
<h1 id="logo">
<a href=""><span>Stack Overflow</span></a>
</h1>
/* position code, it may be absolute position or normal - depends on other parts of your site */
#logo {
...
}
#logo a {
display:block;
width: actual_image_width;
height: actual_image_height;
background: url(image.png) no-repeat left top;
}
/* for accessibility reasons - without styles variant*/
#logo a span {display: none}
Please note that I have removed all other CSS styles and hacks because they didn't correspond to the task. They may be usefull in particular cases only.
Chiming in a bit late here, but couldn't resist.
You're question is half-flawed. Let me explain:
The first half of your question, on image replacement, is a valid question, and my opinion is that for a logo, a simple image; an alt attribute; and CSS for its positioning are sufficient.
The second half of your question, on the "SEO value" of the H1 for a logo is the wrong approach to deciding on which elements to use for different types of content.
A logo isn't a primary heading, or even a heading at all, and using the H1 element to markup the logo on each page of your site will do (slightly) more harm than good for your rankings. Semantically, headings (H1 - H6) are appropriate for, well, just that: headings and subheadings for content.
In HTML5, more than one heading is allowed per page, but a logo isn't deserving of one of them. Your logo, which might be a fuzzy green widget and some text is in an image off to the side of the header for a reason - it's sort of a "stamp", not a hierarchical element to structure your content. The first (whether you use more depends on your heading hierarchy) H1 of each page of your site should headline its subject matter. The main primary heading of your index page might be 'The Best Source For Fuzzy Green Widgets in NYC'. The primary heading on another page might be 'Shipping Details for Our Fuzzy Widgets'. On another page, it may be 'About Bert's Fuzzy Widgets Inc.'. You get the idea.
Side note: As incredible as it sounds, don't look at the source of Google-owned web properties for examples of correct markup. This is a whole post unto itself.
To get the most "SEO value" out HTML and its elements, take a look at the HTML5 specs, and make make markup decisions based on (HTML) semantics and value to users before search engines, and you'll have better success with your SEO.
I think you'd be interested in the H1 debate. It's a debate about whether to use the h1 element for the page's title or for the logo.
Personally I'd go with your first suggestion, something along these lines:
<div id="header">
<a href="http://example.com/"><img src="images/logo.png" id="site-logo" alt="MyCorp" /></a>
</div>
<!-- or alternatively (with css in a stylesheet ofc-->
<div id="header">
<div id="logo" style="background: url('logo.png'); display: block;
float: left; width: 100px; height: 50px;">
<a href="#" style="display: block; height: 50px; width: 100px;">
<span style="visibility: hidden;">Homepage</span>
</a>
</div>
<!-- with css in a stylesheet: -->
<div id="logo"><a href="#"><span>Homepage</span></a></div>
</div>
<div id="body">
<h1>About Us</h1>
<p>MyCorp has been dealing in narcotics for over nine-thousand years...</p>
</div>
Of course this depends on whether your design uses page titles but this is my stance on this issue.
<h1>
<a href="http://stackoverflow.com">
Stack Overflow<img src="logo.png" alt="Stack Overflow" />
</a>
</h1>
This was the good option for SEO because SEO gives the H1 tag high priority, inside the h1 tag should be your site name. Using this method if you search the site name in SEO it will show your site logo as well.
you want to hide the site name OR text please use text-indent in negative value. ex
h1 a {
text-indent: -99999px;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With