Better alternative to text-indent:-9999px

Posted on October 8th, 2009 by Jeff Lin

Thanks to David Reese for this great tip. Instead of this:

text-indent: -9999px; height: 20px;

you just do:

height: 0; overflow: hidden; padding-top: 20px;

3 Comments so far

1 | Joshua Clanton

I’m curious as to why this is supposed to be a better alternative. Isn’t it just another way of achieving the same thing?

Posted at 9:12 pm on January 22nd, 2010
2 | Jeff Lin

Hey Joshua, in Firefox if you use a negative text indent on an <a> you will get an outline of the link that goes -9999px off the screen. There are ways to prevent this using focus {outline:none;}, but you don’t need it if you use the method described above.

Posted at 12:35 pm on January 23rd, 2010
3 | Anonymous

Excellent, thanks!

Posted at 2:35 pm on February 16th, 2010

Write a new comment


Comment: