Image Replacement using CSS

30 Jun

Image Replacement using CSS

November 21, 2007 • 0 comments

Most web designers have all used one sort of image replacement technique somewhere. (This blog uses sIFR for the title) However the most common method for image replacement is the Revised Phark Method. This method still allows for semantic XHTML code and is accessible to screen readers.

The technique is quite simple, you use the text-indent CSS property and indent your text negatively so far off the screen it doesn’t show up. Designers have come to adopt -9999px or -9000px. This value insures that if you have a right aligned header and the site is being displayed on a large monitor, your text will still be pushed off screen.

Using this method you can put push your text off the screen and replace it with an image or logo and still have semantic and accessible XHTML. Of course you can also link it so that it returns to your home page as is generally practiced.

Company Name

In the CSS you want to make sure that you define a width and height for the image, otherwise the element will colapse onto itself.

/* css */
#header {
text-indent: -9999px;
background: url(logo.gif);
width: 300px:
height: 25px;
}

This code shows how you can replace an tag with an image, yet keeping the visible to screen readers and search engine robots. However Firefox creates slight problem with links. Theres a thin dotted outline around the tags. Ever since version 1.5 Firefox has started to include the -9999px indention, so the border goes to the far left of the screen at when the link is clicked.

In the next entry we’ll see how to get rid of the dotted line border on the links in Firefox.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: