CSS color & background-color
- type
- property
- applies to
- any element (color: text; background-color: fill)
- inherits
- color: yes — background-color: no
- common values
- named (red), hex (#222), rgb(), hsl()
Where it goes
color on anything with text in it. background-color on any box.
Example
body {
color: #222;
background-color: #fafafa;
}Common mistakes
- Setting a light background without checking that the text color still stands out against it.
- Expecting background-color to pass down like color does. A parent's background never spreads to the tags inside it on its own.