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.

CSS defines three “global” keywords that are accepted by every property in the specification:

inherit

Forces the value for the property to be inherited from the element’s parent element, even if the property in question is not inherited (e.g., background-image). Another way to think of this is that the value is copied from the parent element.

initial

Forces the value of the property to be the initial value defined by the relevant CSS module. For example, font-style: initial sets the value of font-style to normal regardless of the font-style value that would have been inherited from the parent element. In cases where the initial value is defined as determined by the user agent, such as for font-size, the value is set to the “default” defined by the user agent’s preferences.

unset

Combines the effects of both inherit and initial, with a rudimentary logic built in for good measure. If a property is inherited (e.g., color), then unset has the same effect as inherit. If the property is not inherited ...

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