Ultimate CSS Reference

Page 41

General Syntax and Nomenclature

25

Each declaration includes a property name and a value, separated by a colon.

Statements A CSS style sheet is composed from a list of statements. A statement is either an at-rule (p. 25) or a rule set (p. 26). The following example has two statements; the first is an at-rule that is delimited by the semicolon at the end of the first line, and the second is a rule set that is delimited by the closing curly brace, }: @import url(base.css);

h2 {

color: #666;

font-weight: bold;

}

An at-rule is an instruction or directive to the CSS parser. It starts with an at-keyword: an @ character followed by an identifier (p. 43). An at-rule can comprise a block delimited by curly braces, {}, or text terminated by a semicolon, ;. An at-rule’s syntax will dictate whether it needs a block or text—see At-rules Reference (p. 47) for more information. Parentheses, brackets, and braces must appear as matching pairs and can be nested within the at-rule. Single and double quotes must also appear in matching pairs. Here’s an example of an at-rule that requires a block—the @media (p. 51) at-rule: @media print {

body {

font-size: 12pt;

}

}

Here’s an example of an at-rule terminated by a semicolon—the @import (p. 49) at-rule:

General Syntax and Nomenclature

At-rules


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.