Performance: Background color
Background color affects the paint phase of page rendering, influencing how quickly the browser can display visible content.
Jump into concepts and practice - no test required
body { background-color: #ffffff; }body { background: linear-gradient(to right, #fff, #eee); }| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Solid background-color | None | None | Low paint cost | [OK] Good |
| Background with gradient | None | None | Higher paint cost due to gradient rendering | [X] Bad |
background-color do?background-color property sets the color behind the content and padding of an element.color, borders by border, and font style by font-style.background-color.property: value;, so background-color: blue; is correct.div {
background-color: #ff0000;
}#ff0000 means full red, zero green, zero blue.p {
background-color = yellow;
}#d3d3d3 and rgb(211,211,211) represent light gray; color names like 'lightgray' also work.