Colour and background properties

Colours, used carefully, greatly enhance the appearance of a document. CSS is able to specify a colour for the text itself, and for the area behind the text. For example, the content of a Warning element could be displayed in red text on a yellow background.

Colors

The 'color' property specifies the colour of the text:

warning   { ... ; color: red }

The 'background-color' property specifies the colour of the background, both behind the text and in the padding area (see below). Apart from the name of a colour, the value can be 'transparent', meaning that the existing background colour shows through, and this is the default setting:

warning   { ... ; background-color: yellow }

para   { ... ; background-color: transparent ...

Get XML Companion, The, Third Edition 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.