Prev | Current Page 192 | Next

Tommy Olsson and Paul O'Brien

"The Ultimate CSS Reference"

This is a common cause of head scratching among those
new to CSS, who often think that a class selector will be specific enough to match
an element in all cases.
133 The Cascade, Specificity, and Inheritance
Inheritance
Inheritance is the process by which properties are passed from parent to child
elements even though those properties have not been explicitly defined by other
means. Certain properties are inherited automatically, and as the name implies, a
child element will take on the characteristics of its parent with regards to these
properties.
Inheritance and the Cascade
Inheritance is a mechanism that??™s separate from the cascade: inheritance applies to
the DOM (Document Object Model) tree, while the cascade deals with the style
sheet rules. However, CSS properties set on an element via the cascade can be
inherited by that element??™s child elements.
For example, if a div element has a font-size of 20px then, assuming that no other
font-size declarations have been explicitly defined, any children will also inherit
that font-size value.


Pages:
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204