Understanding Cascades

You can use multiple stylesheets for one XML document in several ways because there are multiple ways of attaching stylesheets. For example, you can use the <?xml-stylesheet?> processing instruction, and you can use the @import directive (for example, this directive will import a stylesheet: @import url(http://www.starpowder.com/ch09_02.css); ) in a stylesheet to import another stylesheet. The reader of a document may use browser-specific techniques to use stylesheets, and the reader's software can even supply default stylesheets.

In addition, the author or reader of a document can use another declaration, the !important declaration, to specify that some aspect of a style should not be overridden by inheritance. (For example, this declaration specifies that it's important for <U> elements to color their text red: U {color: red!important text-decoration: underline} .)

So when multiple style rules are involved, what order are they applied in? Generally, the most specific rules are the ones that are applied if there is a conflict. For example, rules that you apply by ID are preferred to those applied by class. However, rules applied by class are preferred to those applied to all elements of the same type. If no selector fits the situation, the element will inherit styles from its parent; if there is no parent, a default style is used.

If there's a conflict, rules that the document author specified as important are preferred, followed by rules that the reader specified as important, followed by general author rules (that is, those not marked as important), followed by general reader rules, and finally followed by the most recent rule in the applicable stylesheet(s).



Real World XML
Real World XML (2nd Edition)
ISBN: 0735712867
EAN: 2147483647
Year: 2005
Pages: 440
Authors: Steve Holzner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net