Semantically correct website logos

Created on July 18, 2010 by Garrett Winder

How to mark up your website logo has always been a really controversial topic on the web. There are literally hundreds of articles about the topic and, well, this is another one.

Over the past year we've changed our approach to this extremely boring (but important) subject 3 times. Below I will hit on each one and follow up with how we're doing it now - which in my opinion is the "right" way.

H1 Image Overlay

This approach seems right; throw an anchor in your H1 with your company name written inside of it, hide the text with CSS and show the logo. Secondary page titles start with H2 and make their way down, etc.

The HTML

<h1>
 <a href="#" title="Company Name">Company Name</a>
</h1>

The CSS

h1 {
 text-indent: -9999em;
}

h1, h1 a {
 height: 50px;
 width: 230px;
}

h1 a {
 background: url("logo.png") no-repeat;
 display: block;
}

Problems with this approach

  1. We're hiding text, which is tedious and could possibly hurt search rankings… though I have no idea if it really does or not. I'll be safe.
  2. Our Secondary page titles shouldn't be H2's, they should be H1's.

After researching a little bit I eventually found this video by Google on YouTube. The video basically says to use alt, not css, so thats what we started doing.

H1 w/ Image in the markup

According to our friends at Google, this approach is "better". You simply put an image tag inside of your H1 and put your company name in the images alt tag. But still, secondary pages start with H2.

<h1>
 <a href="#" title="Company Name">
  <img src="logo.png" width="" height="" alt="Company name">
 </a>
</h1>

After sticking around here for a while, and still not being satisfied, I came across a comment #47 on 456 Berea Streets article, Headings, heading hierarchy, and document outlines. Perfect!

The "right" way to markup your website logo

Homepage Logo

<h1>
 <a href="#" title="Company Name">
  <img src="logo.png" width="" height="" alt="Company name">
 </a>
</h1>

Secondary page Logo

<p>
 <strong>
  <a href="#" title="Company Name">
   <img src="logo.png" width="" height="" alt="Company name">
  </a>
 </strong>
</p>

If your website was a book, the homepage would be its cover. The secondary pages are the books chapters and the H1 should be used for the "chapter titles", not the "book's title".

So, that's our approach. I know there are a million approaches out there but in my opinion this is the "best" way to semantically markup your websites logo.

Like what you see here? Share the love!

If you liked this article, feel free to share it. We won't stop you.

You can also stay up to date by follow us on Twitter or subscribing to our newsletter.

Comments

Why not just use an image since your logo is an image to begin with?
- by Brandon Livengood on Jul 19, 2010 at 4:10 PM

We do use an image, but we wrap it in either an H1 or a strong because it's more than just any image, it's essentially the heading of the entire site.
- by Garrett Winder on Jul 19, 2010 at 4:15 PM

I was under the impression that you should only semantically use one h1 tag per page.

As exhibited here:
http://www.w3.org/QA/Tips/Use_h1_for_Title

http://www.flexewebs.com/semantix/semantic-uses-of-h1-h2-h6-html-tags/


- by Chris O'Sullivan on Jul 20, 2010 at 5:56 AM

@chris - It doesn't say anywhere in this article that you should have more than one H1 per page.

But, you can: http://html5doctor.com/the-header-element/
- by Garrett Winder on Jul 20, 2010 at 6:30 AM

IMHO <h1> should be used for the page title, not a website title since it should describe the entire purpose of the page since it is so weighty semantically. Logo's and other branding serve only the branding purpose, not content.
- by Luke Morton on Jul 20, 2010 at 6:53 AM

This topic was a serious debate a while ago when I launched the H1 Debate.

In short, I think the company/site name should be the H1 on the home page, and the page title should be the H1 on inner pages.
- by Paul Randall on Jul 20, 2010 at 7:58 AM

@Luke - I think we agree w/ each other for the most part.

@Paul - Wonderful site - hadn't seen that one. And I agree, my point exactly.
- by Garrett Winder on Jul 20, 2010 at 8:03 AM

Hold on a minute... I'm confused... What happened to the <marquee> tag??
- by Chad Hutchins on Jul 20, 2010 at 8:32 AM

@Luke, I was thinking the same thing, but when I went back and reread I noticed, "If your website was a book, the homepage [...]".

I believe the post is saying you use H1 on the homepage, but not on the rest of the site.
- by Jacob Harvey on Jul 20, 2010 at 8:35 AM

@chad Don't you worry good buddy, the <marquee> tag is here to stay!

@Jacob That's what I meant, sorry for the confusion.
- by Garrett Winder on Jul 20, 2010 at 8:57 AM

Another way. You could also do a sprite with this method.
HTML:
<div id="logo"><h1><span>My company creates awesome things</span></h1></div>

CSS:
#logo h1 {font-size:1.5em; margin:0; padding:0}
#logo h1 a { background:url("../images/header_02.jpg") no-repeat scroll left top #333A3F; color:#FFFFFF; display:block; height:77px}
#logo h1 a span {display:block;width:0; height:0; overflow:hidden}
- by Paul on Jul 20, 2010 at 6:40 PM

h1 should be used to header the page's content, not the logo on every page.

If on the homepage it *makes sense* to wrap the logo in a h1, then do so, but subsequent headings should not be h1.


- by matt on Jul 21, 2010 at 5:53 AM

Pros & Cons whether to display your logo as an image w/ alt text or via css background & "hidden" text. I favour the css route.

I did use {text-indent:-9999px}, but have since been persuaded by a SEO guru friend that "hiding" the text is more SE friendly using {height:0; overflow:hidden}

<a id="logo">Company: leaders in blah blah</a>

a#logo{height:0; overflow:hidden; background:url("logo.png"); padding-top:(logo.png height);}


- by matt on Jul 21, 2010 at 5:54 AM

What really annoys me personally that the subject of semantics, top-most headers and logos nearly always boils down to styling. I believe there is only one semantically correct way: you don't mix your h1's and logo. More on this here: http://chromice.com/post/837106594/semantically-correct-website-logos
- by Anton Muraviev on Jul 21, 2010 at 6:40 AM

@matt - Thanks, Matt. That's my point of the article exactly.
- by Garrett Winder on Jul 21, 2010 at 8:30 AM

So, why can't the logo/brand be the <h1> on every page and subsequent titles start at <h2>? Not getting that one…
- by Levi Figueira on Jul 30, 2010 at 7:22 PM

The main title of a secondary page shouldn't be an <h2>, it should be an <h1>
- by Garrett Winder on Jul 30, 2010 at 7:32 PM

The <h1> should always be used for the title of the website document (I use document here to name a page, an article, a product subpage etc. - anything within the scope of your website that can be reached via a unique URI) you're currently viewing. Taking the example of a blog, the <h1> should be used for the headline of the blog entry you're looking at (we're on the entry's unique subpage here), as it is, indeed, the title of the document you're reading. It can be argued that […]
- by Søren on Aug 16, 2010 at 4:45 PM

[continued] the blog's name is the "headline" for the homepage and as such should be wrapped in a <h1> tag. As long as there is no better title, this approach is correct.

I would, however, think twice about saying that it's "semantically correct" to wrap the logo/website name in a tag on all other pages, as advocated above. While it is techically true to assert that the logo introduces all following content […]
- by Søren on Aug 16, 2010 at 4:46 PM

[continued] on the homepage and as such assumes the role of a headline, it never turns into a paragraph of text (which is the semantic meaning of ) on any page. That's just wrong. It would be better to use a plain <div> tag or adopt HTML5 speak and use <header>.
- by Søren on Aug 16, 2010 at 4:47 PM

Thanks for the input smile
- by Garrett Winder on Aug 16, 2010 at 5:07 PM

Leave a Comment


or