Chapter 2. Values

There are a variety of value types in CSS, most of which use units. Combining basic value types (such as numbers) with units (such as pixels) makes it possible to do any number of interesting things with CSS.

Keywords

Keywords are defined on a per-property basis and have a meaning specific only to a given property. For example, normal has totally unique meanings for the properties font-variant and letter-spacing. Keywords, like property names, are not case-sensitive. A special case is the keyword inherit, which is allowed on all properties and always has the same meaning (get the associated property’s value from the element’s parent). There is a second special universal keyword, initial, which is meant to represent the initial or default value for a given property. Thus, declaring font-family: initial would return the browser’s preferences-based default font family. (Times, for most people.) The status and application of initial is unclear as of this writing and may be unreliable.

Color Values

#RRGGBB

This is a hex-pair notation familiar to authors using traditional HTML. In this format, the first pair of digits corresponds to the red level, the second pair to the green, and the third pair to the blue. Each pair is in hexadecimal notation in the range 00-FF. Thus, a “pure” blue is written #0000FF, a “pure” red is written #FF0000, and so on.

#RGB

This is a shorter form of the six-digit notation described previously. In this format, each digit is replicated to arrive ...

Get CSS Pocket Reference, 4th 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.