Using the Background Shorthand Property

In CSS, the background shorthand property can be used to set any of the other background properties (background-color, background-image, background-repeat, background-attachment, and background-position). The background property first sets all of the background properties to their initial values and then assigns any explicit values stated in the declaration. For instance, the previous example of setting multiple background properties can be reduced to a single background property in this manner:

body {  color: rgb(153,0,0); background: rgb(238,238,213) url("watermark.gif") no-
repeat 50% 5em fixed; }

TIP

Because some earlier CSS-supporting browsers support the background property, but not the background-color ...

Get Cascading Style Sheets (CSS) by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.