websitewriters.co.za
Standards Compliant Web Design in South AfricaThe "Right" way to use an image as your header title
Posted by Raoul Snyman on March 7, 2006 on 1:46 pm | In Accessibility |You can use css (cascaded stylesheets) to make your site more accessible to everyone, including those with sight problems.
For instance:
Your site uses a nice large image as it’s title logo. While it’s cool for those who can see, what about those who can’t see? They use screen readers, which basically read out what’s on the screen. The only problem is that when a screen reader comes to an image, it just says “image”. Bummer… now where’s your web site title?
Here’s a little trick I thought of to overcome that particular problem, but one which could be used elsewhere.
create a div with a heading:
<div id="header">
<h1>mp3taxi.com</h1>
</div>
Then, in your css file, you set your h1 to not display, and your div to show the image, like so:
#header
{
background: url(../images/main_logo.png) no-repeat top left;
}
#header h1
{
display: none;
}
So then what happens is that your image shows in css-enabled browsers, and in other browsers, you see the heading, “mp3taxi.com” in nice big letters.
Now, if you go to the site I’ve just been using as an example, you’ll see that there’s another background image that stretches across the whole of that header section, as well as the title header… I simply added a span in, and rearranged my css slightly… see below:
<div id="header">
<h1><span>mp3taxi.com<span/></h1>
</div>
#header
{
background: #ffff00 url(../images/headerbg.png) top left repeat-x;
color: #000000;
height: 88px;
}
#header h1
{
margin: 0;
padding: 0;
height: 88px;
width: 281px;
background: url(../images/main_logo.png) no-repeat top left;
float: left;
color: #000000;
}
#header h1 span
{
display: none;
}
with css:

without css:

happy coding!
3 Comments »
RSS feed for comments on this post. TrackBack URI
Leave a comment
You must be logged in to post a comment.
Powered by WordPress with
websitewriters.co.za
theme, design by Saturn Laboratories.
Entries and
comments feeds.
Valid XHTML and
CSS. ^Top^
[…] The Website Writers site has become a blog. Today’s tip is about the proper way to use CSS for your header image. […]
Pingback by A Group of Web AddiCT(s); » Blog Archive » Mark Twain on the use of Statistics — March 8, 2006 #
Not too smart.Googlebot can read css files and it may decide you are hiding content for SEO purposes and drop your page from the SERPs. This happened to me over two years ago and I haven’t used display:none for keywords since. There are many other image replacement techniques out there, SIFR being the most popular at the moment.You can also use a .off-left class to hide the text, which leverages a negative value for the css rule text-indent to pull your text content off the page, like so:
text-indent:-3000px;See http://www.completechildcare.co.za for an example. Not sure what the longevity of this method is though, its basically just a more obscure implementation of what you suggest above.Comment by lukehardiman — March 8, 2006 #
What I’ve started doing recently is something similar to:
HTML:
<h1><a href="http://url.to.site/"><img src="your-logo.image" alt="site title" /></h1>
CSS:
h1 img a { border:0; }Comment by sn — April 20, 2006 #