Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I'm somewhat of a novice to CSS.

Anyway, I noticed that an extremely common method used in CSS is to have negative or off-screen positioning, whether it be to hide text or preload images or what have you.

Even on SE sites, like StackOverflow and this website, have

#hlogo a { text-indent: -999999em } 

set in their CSS.

So I guess I have a few questions.

  • is this valid CSS? or is it just a "hack"?
  • are there downsides to doing things this way?
  • why is this so common? aren't there better ways to hide content?
share|improve this question
add comment

2 Answers

It is valid, and it's screen reader friendly. However I wouldn't recommend over doing it, because Google may see it as a blackhat technique since a lot of spammers use negative indentation to hide links.

share|improve this answer
add comment
  1. It's valid, and it's a "hack" only that you are using a large negative indent to hide text, probably not designed with that in mind.
  2. Yes, the text cannot be seen.
  3. Depends, for SEO purposes the text is there, yet normally replaced by an image or icon.
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.