If multiple values must occur in a certain order, they are given as a list. The following example could be used in the definition of a property that always required a color and a number (there is no such property in CSS1; this is just an example):
Vertical Bars | and ||: A single vertical bar | separates alternative values. For example, in A|B, the | separates A and B; either A or B will be used. You may have any number of alternatives. One and only one of the alternatives must occur. In the following examples, exactly one of the listed values must occur:
A double vertical bar | | also separates alternative values; for example, A | | B. However, the | | means that either A or B or both must occur. Further, they may occur in any order. In the following example, there may be a color or a url or both, and their order is not important:
Another example, slightly more complicated, is taken from the definition of the border property, which has a value defined as follows. The types border-width and border-style are defined in Chapter 8, "Space Around Boxes."
Curly brackets { }: Curly brackets { } indicate that the preceding value may occur at least A and, at most, B times. This is written as {A, B}. For example, in the following example, a length value may occur one, two, three, or four times:
In this example, we use the margin property to set a different margin for each of the four sides of a P element. See Chapter 8 for a complete definition of margin. Question marks (?), asterisks (*), and plus (+): Any type or keyword may be followed by one of the modifiers +, *, or ?. A plus (+) indicates that the preceding item may be repeated. The item must occur one or more times.
An asterisk (*) indicates that the preceding item may be repeated, but it may also be omitted. It may occur zero or more times.
Note that the last example has no value at all. A question mark (?) indicates that the preceding type or keyword is optional.
In this example, the available values are a url and a color. <url> is followed by a ?, while <color> is not. Hence, the URL may be omitted, but the color may not. The background property has a value similar to that and, in that property, the presence of both values means that the color is displayed with the image on top of it. If the image pointed to by the url is unavailable, just the color is displayed. Regular brackets [ ]: Regular ("square") brackets group parts of the definition together. A question mark, asterisk, or other special symbol that follows the closing bracket applies to the entire group. The following example shows a group with a vertical bar inside and curly braces on the outside to indicate that the entire group may be repeated between one and four times.
In each case, there are between one and four values, and each of the values is either a length or a percentage. Here is another, more complex example. It is a simplification of the definition of font-family.
The group has an asterisk to indicate that it can occur zero or more times. The group itself consists of a family-name and a comma. In the first example, the group occurs twice there are two families and two commas while in the second example, the group is completely absent; just generic-family appears. |