Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are there CSS rules using -9999px

Tags:

css

On the Twitter site, I found the following CSS rules:

.ProfileCanopy-headerBg img {
  position: absolute;
  left: 0;
  right: 0;
  top: -9999px;
  bottom: -9999px;
  margin: auto 0;
  width: 100%;
} 

What could be the reason for the limit -9999px?

like image 298
html_programmer Avatar asked Nov 20 '25 22:11

html_programmer


1 Answers

It's a way to hide an element that still allows screen readers (and similar technologies) to read the contents, unlike if you were to use, say, display: none.

The value 9999px is arbitrary. Can be any negative number really but I guess it feels safer to really shove it far away :P

like image 71
powerbuoy Avatar answered Nov 22 '25 12:11

powerbuoy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!