Widely availableFoundational and safe, provided contrast and state differentiation are handled carefully.

Overview

background-color sets the fill color behind an element’s content and padding. It is a basic tool for surface grouping, emphasis, and readable contrast.

Browser support

Feature Desktop Mobile
Chrome
Edge
Firefox
Safari
Chrome Android
Safari iOS
1
12
1
1
18
1
transparent
1
12
1
1
18
1
1+Supported (version) Not supported Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)

Syntax

CSS
.card {
  background-color: #ffffff;
}
.highlight {
  background-color: rgba(255, 235, 59, 0.3);
}

Live demo

soridcol-

CSS soridcol- demo.

PreviewFullscreen

semi-transparentbackground

CSS semi-transparentbackground demo.

PreviewFullscreen

Hover state

CSS hover in change demo.

PreviewFullscreen

Use cases

  • Surface grouping

    Differentiate cards, alerts, and containers from the page background.

  • Status emphasis

    Support positive, warning, or error styling with meaningful background treatments.

Cautions

  • Background color alone should not be the only signal of status or meaning.
  • Theme changes can expose weak color combinations if contrast is not tested systematically.

Accessibility

  • Always verify text and icon contrast against the chosen background color.

Powered by web-features