Rule Structure
A style sheet consists of one or more rules that describe how page elements should be presented. Every rule has two fundamental parts: the selector and the declaration block. Figure 1-1 illustrates the structure of a rule.
On the left side of the rule, we find the selector, which selects the parts of the document to which the rule should be applied. On the right side of the rule, we have the declaration block. A declaration block is made up of one or more declarations; each declaration is a combination of a CSS property and a value of that property.
The declaration block is always enclosed in curly braces. A declaration block can contain several declarations; each declaration must be terminated with a semicolon (;
). The exception is the final declaration in a declaration block, for which the semicolon is optional.
Each property, which represents a particular stylistic parameter, is separated from its value by a colon (:
). Property names in CSS are not case-sensitive. Legal values for a property are defined by the property description. The "Property Reference" section, later in this book, provides details on acceptable values for CSS properties.
Get CSS Pocket Reference, 3rd 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.