Currently Browsing: Home » Creating Clever Logo Banners

Creating Clever Logo Banners

Good designs are always clever. They need something to help them stand out from the rest. Here’s how to create a clever logo banner that looks good and is SEO Friendly, like the one Lateral Code uses, using an image and some clever CSS.

The first step is to create the banner. For demonstration purposes, the following banner will be used:
Sample Logo

This is the markup involved:


<div id="logo">
	<h1><a href="/" title="Home Page"><span>Sample Logo</span></a></h1>
</div>


with the following CSS:


#logo {
    background:url(path_to_banner.jpg);
    width:780px;
    height:100px;
}

That part is easy enough. The next step is a little bit of clever CSS and some measurements.

Measuring the Sample Logo

In this example, the Logo runs from 62px to 234px horizontally, and 34px to 78px vertically, or 172x44px, so we add the following CSS:


#logo h1 a {
    display:block;
    width:172px;
    height:44px;
}

And to position it, we add to #logo:


#logo {
    background:url(path_to_banner.jpg);
    width:718px;
    height:66px;
    padding-left:62px;
    padding-top:34px;
}

Notice that I have shrunk the width and the height. This is because of how the CSS Box Model works – the actual width is the specified width added to the padding.

Now we are stuck with a problem: the text from the HTML overlays the text in the image, making it look unappealing. The reason we wrap the text in a span is so we can hide it, like so:


#logo h1 a span {
    display:none;
}

And it looks great.

As a bonus tip, you can increase interactivity by having the image show a friendly tip on hover – which, unfortunately, does not work in Internet Explorer 6.

We do this using a technique known as CSS Spriting – putting two images in one and only displaying part of it at a time. Here, I duplicate the image vertically and put an extra tidbit on the second one.

Sprited Logo

Because we set #logo to a specified height, the part below what we want to show gets hidden. Then we add the hover effect:


#logo:hover {
    background-position:0 -100px;
}

Then, when the user hovers over logo, it shifts the background position and shows the second image, that has the tip.

So the final CSS is:


#logo {
    background:url(path_to_banner.jpg);
    width:718px;
    height:66px;
    padding-left:62px;
    padding-top:34px;
}
#logo:hover {
    background-position:0 -100px;
}
#logo h1 a {
    display:block;
    width:172px;
    height:44px;
}
#logo h1 a span {
    display:none;
}

To create the effect.

Of course, to make it work in Internet Explorer 6, it is possible to use jQuery to add the hover effect that CSS isn’t able to:


$(function() {
    $("#logo").hover(function() {
        $(this).css("backgroundPosition", "0 -100px");
    },
    function() {
        $(this).css("backgroundPosition","0 0");
    });
});

And there you have it.

Tags: , ,

This entry was posted on Monday, January 26th, 2009 at 23:04:24. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

3 Responses to “Creating Clever Logo Banners”

  1. Jason says:

    Hello,

    It is quite clear that you know more about all of this than I do, when looking at this post something that comes to mind is that I read google etc. will demote a site if it has hidden text, and so I wondered how this concern would relate to setting the html element to not display? If the way it is done here is not a way that is currently demoted by google, is it likely that they would later demote it when they realize that this is being done?
    Thank you very much for your time, efforts, and tips! – Jason

  2. Patrick Lin says:

    Hi Jason,

    What Google demotes on is not using display:none to hide text to make something look good, but when you abuse it to hide spammy things.

    Matt Cutts, an employee at Google, wrote:

    A lot of my site visitors assumed that this was an instance of “have a logo, and use CSS to display text instead of the logo as a fallback”. That wasn’t what was happening. It was straight out using CSS to hide text, and it was clearly spam.

    If you’re straight-out using CSS to hide text, don’t be surprised if that is called spam. I’m not saying that mouseovers or DHTML text or have-a-logo-but-also-have-text is spam; I answered that last one at a conference when I said “imagine how it would look to a visitor, a competitor, or someone checking out a spam report. If you show your company’s name and it’s Expo Markers instead of an Expo Markers logo, you should be fine. If the text you decide to show is ‘Expo Markers cheap online discount buy online Expo Markers sale …’ then I would be more cautious, because that can look bad.”

    (Source)

    I hope that answers your question.

    Patrick

  1. Placing Links In Images - Lateral Code

Leave a Reply

Want to be notified when someone replies? Subscribe to this post's comment RSS feed.
Any field marked with a * is required.