HTML and CSS Reference
In-Depth Information
@media print {
The cascading in CSS is the process that is followed in order to determine
which declaration for a given property is applied to a given element in
the document. As you'll soon learn, properties— color , for instance—can
be defined and redefined multiple times, so the browser must determine
which of those definitions to apply. The criteria for sorting through the
style sheets to determine which property declaration to use is threefold:
weight, specificity, and order of appearance.
The weight of the declaration is determined by the origin of the style
rule. Style rules can be found in one of three sources in descending order
of weight:
Author style sheets : These are the style sheets defined along with the
source HTML document by the author of the page visited.
User style sheets : User style sheets are CSS documents or other styling
preferences selected by the user of the browser.
User agent style sheets : Each user agent applies a default set of presen-
tation rules representing common behaviors for each HTML element
(links are highlighted, headings are larger, and so on).
You can learn more about the sources of styling rules in Chapter 2.
The specificity of the declaration is determined by how precise the
selector used for the element is. A selector that states “any paragraph
element” ( <p> ) is less specific than a selector looking for “any paragraph
that occurs inside of a block quote” ( <blockquote><p> ).
Search WWH ::

Custom Search