5.1. Specifying Style Rules

HTML elements are customized by the use of style rules. The most common practice is to place the style rules in a separate text file and refer to the text file through a LINK element located in the HEAD section of the document. However, style rules can also be placed directly in the HEAD section of an HTML document or in the body of the document. Style rules are of the form

selector { property: value }

or

selector { property1: value1;
           property2: value2;
           ...
           propertyN: valueN }

Note that multiple properties for a single selector should end in a semicolon; the last property of a selector does not require a semicolon.

The types of selectors that can be used are discussed in Section 5.3, but the most basic type is ...

Get Core Web Programming, Second 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.