]> Cascading of SGML/HTML style sheets

Cascading of SGML/HTML style sheets

It should be possible to combine style sheets, so that the result is some combination of the rules of the constituents. When the combined style sheets have no overlapping rules, there is problem, but it is often useful to combine two style sheets in such a way that one can be seen as a set of exceptions (or overrides) to the other.

In principle, style sheets can come from two sides: the style sheets linked to a document by the document's author and the style sheet that the user applies to that document. Assuming just two levels of priority (high and low), the following scheme could be used:

  1. If the document has no style sheets of its own, a style sheet chosen by the application (i.e., the user) is applied.

  2. If the document mentions one or more style sheets:

    1. Combine all fragments that are attached to the document. If there are rules with the same major as well as minor priorities, then the last one overrides earlier ones.

    2. Split this style sheet in two parts: one with all rules of low major priority and one with rules of high major priority.

    3. Also split the user's style sheet in two parts.

    4. Combine the rules of high priority with each other, in such a way that the author's rules override the user's rules.

    5. Finally combine the resulting set of high priority rules with the author's low priority rules. (Note that the user's low priority rules are not used.)

Stated in other words: the user's low priority rules only apply in the absence of rules by the author. The user's high priority rules can be used to override the author's low priority rules, but the author can in in turn override these rules.

In this scheme the author has the final say, but that is only if the user coorperates. The user can instruct his browser to leave out the author's rules as a whole or in part, or he can change the priority of the author's rules.

It remains to be discussed whether more than two levels of priority are necessary.

The author's rights vs the user's rights

To restore some confidence to the author, a well-designed browser should not remove the author's high priority rules without either warning the user or requiring him to take some explicit action.

Indeed, it may be an idea to let the author define the warning message that should be displayed in this case. Instead of the default warning, the user will then be able to read why the author thinks it necessary to use high priority rules.

(Back) to style sheet overview

Bert Bos, 11 May 1995