By using this site you agree to the use of cookies by Brugbart and our partners.

Learn more

CSS Background Property

Reference on the CSS Background Property.

Edited: 2015-02-21 14:58

The background property sets the background for a given element, in one declaration, making it easier to specify background images.

You can also use data URLs when specifying a background image, this helps to speed up your pages load time.

Tutorial: Setting a Background URL with CSS

Possible Values

Using this property, you can specify both the background-color, background-image, background-attachment, and background-position.

See also: Reference on Colors

body {
  background: red url("MyBackground.png") fixed no-repeat top left;

Which is the equivalent of:

body {
  background-color: red;
  background-image: url("MyBackground.png");
  background-attachment: fixed;
  background-repeat: no-repeat;
  background-position: top left;

Inherited? - NO!