CKTIS / CSS
background-color — background color
The background-color property sets an element’s background color beneath its background images. Its initial value is transparent, and it is not inherited.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
background-color: <color>;background-color sets the background color of an element’s box. It accepts one <color> value, such as #003366, red, rgb(0, 51, 102), or transparent. It does not set text color; use color for that.
The initial value is transparent. The property is not inherited: seeing a parent’s background through a transparent element does not mean its color was inherited.
The color is painted beneath all background images. Its clipping area follows the background-clip value of the bottommost background image layer. A later background shorthand declaration can reset background-color to transparent if it omits a color.
The example creates a dark blue panel with white text and 16px padding. The hexadecimal notation specifies an opaque sRGB color.
Examples
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>background-color</title>
<style>
.panel {
background-color: #003366;
color: #ffffff;
padding: 16px;
}
</style>
<div class="panel">CSS background-color</div>
</html>Result
A dark blue panel (#003366) with white text reading "CSS background-color" and 16px of padding.
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.