If you are reading this, please get modern browser.
skip to main content | skip to main navigation | skip to secondary content

Common CSS Forgettables Part 1

~ 21st September 2005. · 16:48 CET · permanent link · printer friendly ~

This post is a quick reminder to all of us who code and test web sites on Macs. We often take some common Safari behavior for granted, but the reality is a little bit different. No matter how much one dislikes PCs and has an aversion to anything but the divine Mac OS, the truth is – there’s more visitors with IE5.x than with Safari. Said that, here’re the most common CSS flaws. Workarounds included.

Negative text-indent and underline

This one is huge. Even the most respected standards aware ladies and gentlemen are forgetting it, project after project.

The Phark image replacement is very popular, since the screen reader is still able to read the replaced content. Here’s the common HTML and CSS setup:

...
a.replaced {
    display: block;
    width: 100px;
    height: 50px;
    text-indent: -9999px;
    background: url(cool_image.gif);
}
...
<a class="replaced" href="http://www.coolsite.com/">Cool site</a>
...

No matter how far on the left the real text is, the underline will be stretched all the way to the right in some PC browsers, namely the Firefox. So, even though the text itself is virtually somewhere in the next room, I’d say 3.5 meters to your left, the space of the link itself is right there where it has always been – in the browser on your screen.

The trouble is – nobody likes too many default underlines in their designs, but one often applies underline for the hover state, simply to inform the user about interaction existence for the given element. It’s usually done at the beginning in a CSS as a site-wide generic rule and by the time you start styling those replaced links, you completely forgot about the underlines.

The workaround is more than obvious and it’s best to apply it automatically:

...
a.replaced,
a.replaced:hover {
    display: block;
    width: 100px;
    height: 50px;
    text-indent: -9999px;
    background: url(cool_image.gif);
    text-decoration: none;
}
…
<a class="replaced” href="http://www.coolsite.com/">Cool site</a>
…

To be continued…

2 Comments

  1. Well, that’s a thing I surely would have forgotten. Looking forward to reading about specificity rules. I just keep forgetting about them and sometimes it really frustrates me.

  2. heh, that’s why I have
    * {margin: 0; padding: 0; border: none; text-decoration: none;}
    on the beggining of every CSS file so I wouldn’t forget it later ;)

Sorry, the comment form is closed at this time, but if you have anything to say, please send me a message.

* Please keep in mind that this is a personal web site and it does not reflect the position or opinion of my respective employers, organizations or partners.

Typetester – compare screen type Supported by Veer.

What is this?

A web log of Marko Dugonjić, web professional from Croatia. Topics covered:

Translate this site

German, Spanish, Italian, French or Japanese (via).

See you there!

Feel like buying a book?

Try with maratz.com aStore

Worth visiting

top of the page | skip to main content | skip to main navigation | skip to secondary content