What does background: transparent do in Eric Meyer's reset.css?
In Eric Meyer’s reset.css, he adds a background: transparent to just about every HTML element available. I’d like to know why.
Observing members:
0
Composing members:
0
4 Answers
This is used to override any unexpected browser defaults of an opaque background on an element such as <input>. I wouldn’t worry too much about it since it was added to fix unusual browser settings.
transparent is a valid “color” for the background.
So it would really fill the background-color: declaration more specifically and basically is just a version of “none”
Awesome, that makes sense. Thanks guys. (or gals)
As @Vortico notes, if it has precedence in the cascade, it may be to override an earlier background color assignment. Also, the W3C validator issues a warning on elements where the color is explicitly stated but the background is not. This isn’t really an error. It is just telling you that safest practice is to explicitly state both color and background where one is stated. Transparent is the default, so doesn’t really need to be stated unless overriding some assignment further up the cascade, but stating it anyway gets rid of lots of warnings in the validation report, and thus makes zeroing in on real problems far easier. I always state it for just that reason.
Answer this question
This question is in the General Section. Responses must be helpful and on-topic.