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

Remove annoying rectangle in the latest Firefox build

~ 3rd December 2005. · 11:30 CET · permanent link · printer friendly ~

The negative text indent image replacement technique (a.k.a. the Phark image replacement) is very popular and widely used in many modern (i.e. accessible) designs.

There’s, however, this annoying rectangle, which is in Firefox 1.5 now expanded all the way to the left (usually it’s 9999 pixels to the left). The rectangle is ugly, and while we’re waiting for Firefox developers to fix it (report Firefox bugs), here’s a quick and dirty solution:

var remove_rectangle = function() {
    var lnks = document.links;
    if (lnks) {
        for (var i = 0; i < lnks.length; i++) {
            lnks[i].onmousedown = function() {
                this.blur();
                return false;
            }
        }
    }
}
window.onload = function() {
    remove_rectangle();
    // the rest of your onload functions
}

Unfortunately, we can’t remove the rectangle completely, because focus() functionality is necessary for browsing with a keyboard.

Speaking of which, do you always define :focus and :active pseudo-classes or do you sometimes forget about them?

5 Comments

  1. I define :active so I don’t get any surprises. I don’t bother with :focus because the default highlighting of the browser is usually fine.

  2. I had the same problem, fixed it by adding line-height: 0; font-size: 0; to the CSS. That worked for me. Not sure though if that has some drawbacks.

    Another problem (at least I have it) arises from the fact that the rectangle is now dran outside the element—what gave me horizontal scrollbars when I had some links placed to the right boundary of the browser window, viewport… whatever you call it. I “fixed” it by giving the links some room, but that’s not the most elegant solution.

  3. I use the Shea Image Replacement 90% of the time, because when you hide images but leave CSS on, no text appears where the images were.

    I rarely use :focus or :active, as they’re often unnoticeable and thus pointless. There is the occasion where they’re useful, but typically the best indicator is :hover, which is why it’s used most often. Then again, for keyboard-only users, I suppose they’d never see what :hover looks like, so I should probably start using :active.

  4. Easier solution: Use overflow:hidden; on the offending element.

  5. thank you! this entry and its comments helps me a lot! :)

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