22.12.2013 Views

W3C CSS2 Cascading Style Sheets, level 2 - instructional media + ...

W3C CSS2 Cascading Style Sheets, level 2 - instructional media + ...

W3C CSS2 Cascading Style Sheets, level 2 - instructional media + ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

6.1.2 Computed values<br />

Specified values may be absolute (i.e., they are not specified relative to another<br />

value, as in ’red’ or ’2mm’) or relative (i.e., they are specified relative to another<br />

value, as in ’auto’, ’2em’, and ’12%’). For absolute values, no computation is<br />

needed to find the computed value.<br />

Relative values, on the other hand, must be transformed into computed values:<br />

percentages must be multiplied by a reference value (each property defines<br />

which value that is), values with relative units (em, ex, px) must be made absolute<br />

by multiplying with the appropriate font or pixel size, ’auto’ values must be<br />

computed by the formulas given with each property, certain keywords (’smaller’,<br />

’bolder’, ’inherit’) must be replaced according to their definitions.<br />

In most cases, elements inherit computed values. However, there are some<br />

properties whose specified value may be inherited (e.g., the number value for the<br />

’line-height’ property). In the cases where child elements do not inherit the<br />

computed value, this is described in the property definition.<br />

6.1.3 Actual values<br />

A computed value is in principle ready to be used, but a user agent may not be<br />

able to make use of the value in a given environment. For example, a user agent<br />

may only be able to render borders with integer pixel widths and may therefore<br />

have to approximate the computed width. The actual value is the computed value<br />

after any approximations have been applied.<br />

6.2 Inheritance<br />

Some values are inherited by the children of an element in the document tree<br />

[p. 30] . Each property defines [p. 14] whether it is inherited or not.<br />

Suppose there is an H1 element with an emphasizing element (EM) inside:<br />

The headline is important!<br />

If no color has been assigned to the EM element, the emphasized "is" will<br />

inherit the color of the parent element, so if H1 has the color blue, the EM<br />

element will likewise be in blue.<br />

To set a "default" style property for a document, authors may set the property<br />

on the root of the document tree. In HTML, for example, the HTML or BODY<br />

elements can serve this function. Note that this will work even if the author omits<br />

the BODY tag in the HTML source since the HTML parser will infer the missing<br />

tag.<br />

Example(s):<br />

For example, since the ’color’ property is inherited, all descendants of the<br />

BODY element will inherit the color ’black’:<br />

BODY { color: black; }<br />

Specified percentage values are not inherited; computed values are.<br />

Example(s):<br />

For example, given the following style sheet:<br />

70

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!