New Text Hiding Technique, No More Text-Indent:-9999px

Written by on November 20, 2012 in Coding, CSS - No comments
text-indent-9999px

If you’re a website builder you’re most likely familiar with the “negative text indent technique”, a method commonly used to hide text in an element by pushing it off the screen.

Example:

.hidden-text {
     text-indent-9999px
}

Well there’s a new technique in town, promoted over at the zeldman website. Here is the new CSS code to use instead to hide the text:

.hidden-text {
     text-indent: 100%;
     white-space: nowrap;
     overflow: hidden;
}

More lines of text? True. The thought behind the method is that performance will be increased because now the browser isn’t drawing a “9999px” box.

Thanks:
Scott Kellum
Zeldman

Sponsors

About the Author

Mike Ilsley "ilz" is a Boston based website designer, front-end developer, WordPress addict, owner of Beantown Design, and exclusive ThemeForest author. Follow him on Twitter and Facebook, and don't forget to subscribe to the WebDesign&Such email RSS feed. Also, check out his latest project, jQueryMobileShowcase.com.