Color & Background

CSS background Property

Shorthand for all background properties in a single declaration

Syntax

CSS
background: <color> <image> <repeat> <attachment> <position> / <size>;

Values

ValueDescription
noneNo background
#000Solid color background
url() center/coverImage centered and covering
linear-gradient()Gradient background

Example

CSS
.hero {
  background: linear-gradient(135deg, #1e1b4b, #312e81);
}
.card {
  background: #18181b;
}

Understanding CSS background

The CSS background property shorthand for all background properties in a single declaration. As part of the Color & Background module in CSS, it is one of the most commonly used properties for controlling the visual presentation of web pages.

You can set background to values such as none, #000, url() center/cover, linear-gradient(), among others. Each value changes how the browser renders the affected element, giving you fine-grained control over your page layout and design. Choosing the right value depends on the specific design requirements of your project.

Common use cases for the background property include responsive web design, component-based layouts, and creating visually consistent interfaces across devices. It works closely with related properties like background-color, background-image, background-size to achieve complex styling effects. Understanding how these properties interact helps you write cleaner, more maintainable stylesheets.

Browser support for background is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. For older browsers, consider using fallback values or progressive enhancement strategies. The property can also be set dynamically via JavaScript using element.style.background or the CSS custom properties (variables) approach for theming.

Related Properties

Explore More CSS Properties

Browse our complete reference of 251 CSS properties with syntax, examples, and tips.