Setting Colors and Backgrounds

These are the properties you use to set color and backgrounds:

  • color— Sets the foreground (text) color.

  • background-color— Sets the background color.

  • background-image— Sets the background image.

  • background-repeat— Specifies whether the background image should be tiled. You can set this to repeat, repeat-x, repeat-y, or no-repeat.

  • background-attachment— Specifies whether the background scrolls with the rest of the document.

  • background-position— Sets the initial position of the background.

You also can use a background shorthand property to set the background color, image, repeat, attachment, and position all at once (list those values in order). I'll cover how to use this shorthand property at the end of the chapter.

Get Real World XML 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.