Colors

background-color

Learn how to use the CSS background-color property.

CSS background-color

The background-color property sets the background color for an HTML element.

Syntax

.element {
  background-color: #f0f0f0;
}

HTML Context Example

<div class="card">
  This is a styled element.
</div>

<style>
.card {
  background-color: #f0f0f0;
}
</style>

Notes

Experiment in the CSS playground to see how this affects layout and styling.