Classes

Besides elements, you can create selectors using classes. Here's an example. In this case, I'll create a class named RED that specifies that elements it's applied to must use a foreground (text) color of red and a background color of pink; to define a general class such as RED, you must preface it with a dot (.), as in .RED:

Listing . ch09_06.css
 
TITLE {display: block; font-size: 24pt; font-weight: bold;
text-align: center; text-decoration: underline}
AUTHOR {display: block; font-size: 18pt; font-weight: bold;
text-align: center}
SECTION {display: block; font-size: 16pt; font-weight: bold;
text-align: center; font-style: italic}
P {display: block; margin-top: 10}
.RED {color:red; background-color: pink}
				

To apply this class to an individual ...

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.