CSS Shorthand for Backgrounds
Another interesting piece of CSS is that certain properties have a shorthand equivalent. This occurs only with a handful of properties; background
is one of them.
Shorthand properties combine the features of all related properties. In the case of background
, this means that color
, image
, repeat
, and attachment
can all be combined into one rule using the background
property.
To help you compare, Example 8-7 describes the styles for all the background
properties.
Example 8-7. Longhand background styles
body { background-color: white; background-image: url(images/lemon-slice.gif); background-repeat: no-repeat; background-attachment: scroll; background-position: right bottom; ...
Get Spring Into HTML and CSS 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.