Alternate Style Tags defines a pattern for tagging alternate style sheets using a microformat

Introduction

This module defines a pattern for tagging alternate style sheets using a microformat. It can be used to define standardized classes that can be hooked into the browser UI. Sample use cases include horizontal-vertical layout switches in Japanese ebook readers; automatically selecting high-contrast styles; and other accessibility concerns.

[[HTML40]] defines the linking of external style sheets using the link element. Although typically a style sheet is linked in unconditionally, HTML 4 also defines alternate style sets, which are named, mutually-exclusive sets of style sheets that the reader can use to alter the display.

Until now, few [[HTML-LATEST]] user agents have exposed alternate styles in a meaningful way. However, alternate styles are a very simple way to allow the user to alter a document's presentation to his or her preferences and accessibility needs.

This specification takes advantage of the class attribute of the HTML link element (introduced in [[HTML-LATEST]], but supported in many user agents for much longer) to define style tags: a markup pattern for tagging style sheets with standardized class names. These class names can be used by a UA to offer special UI access to such tagged style sets.

The original impetus for this proposal was to offer standard controls for switching between horizontal and vertical layouts in Japanese ebook readers; this use case is addressed in Appendix A, Vertical Text Style Set Tags.

Conformance

None of this specification applies if the UA has unilaterally turned author style sheets off. (This ability is mandated by HTML and CSS.) In this case, of course, all style sheets are disabled.

The [[!CSSOM]] has more low-level controls for controlling whether a given style sheet is enabled or disabled; scripting the CSSOM MAY alter the behavior defined here.

Future versions of this specification will define error handling rules and interaction with [[CSSOM]].

The keywords MUST, MUST NOT, REQUIRED, SHALL, SHALL NOT, SHOULD, SHOULD NOT, RECOMMENDED, MAY, and OPTIONAL in this document are to be interpreted as described in [[!RFC2119]].

All sections and appendixes of this specification are normative except where identified by the informative status label "This section is informative". The application of informative status to sections and appendices applies to all child content and subsections they contain.

All examples in this specification are informative.

Style Sets

This is an informative summary of HTML's declarative alternate style set mechanism, with a few slight changes to terminology.

HTML 4 defines two types of style sheets in its linking mechanism: persistent style sheets and alternate style sheets.

A persistent style sheet is one that is always enabled, regardless of which alternate style set is enabled. A persistent style sheet is indicated by omitting the title attribute from the link or style element that imports it.

An alternate style sheet is one that is part of an alternate set, and can be enabled or disabled as part of that set. An alternate style sheet is indicated by setting a non-empty value for the title attribute of the link or style that imports it. Except for style sheets belonging to a preferred style set (see below), alternate style sheets have to have an alternate value in the rel attribue value addition to the stylesheet value.

HTML allows the grouping of multiple alternate style sheets into a single, named alternate style set. All alternate style sheets with the same title value belong to the same style set.

The author can indicate whether an alternate style set is preferred by omitting the alternate value from the rel attribute of each of its component alternate style sheets. If no preferred style sets are defined, the default preferred style set is an unnamed set containing no alternate style sheets.

By default, the first preferred style set is loaded. The author can override this behavior with the Default-Style meta or HTTP header as defined in [[HTML401]].

Tagging Style Sets

A style sheet can be tagged by adding the tag's name to the class attribute of the link or style element that imports it. Tagging a style sheet with a standard style tag (one defined by a specification referencing this specification) indicates that it implements the functionality described by the style tag's definition. Both alternate style sheets and persistent style sheets MAY be tagged in this way.

A style set can be tagged by tagging any one of its component style sheets. Tagging a style set indicates that it offers the functionality described by the style tag's definition.

Authors using standard tags SHOULD tag all alternate style sheets within a style set with the same set of standard tags.

Future versions of this specification might allow UAs to selectively disable tagged style sheets within a style set. Therefore all alternate style sheets that need to be enabled or disabled together have to have the same set of standard tags.

If two style sheets within a style set are tagged with mutually exclusive tags, both tags are ignored.

A specification that defines style tags MAY indicate that a particular tag is assumed to be the default for untagged style sets.

Vertical Text Style Set Tags

The following style tags are defined by this appendix:

horizontal

This style set provides a primarily horizontal presentation of text. This tag is mutually exclusive with vertical.

vertical

This style set provides a primarily vertical presentation of text. This tag is mutually exclusive with horizontal.

The UA MAY guess whether an untagged style set is horizontal or vertical, or MAY instead assign such a style set an indeterminate state.

Examples

The following examples use XHTML syntax; to use HTML syntax, simply drop the slash before the > in the tags.

Night Vision Style Set Tags

The following style tags are defined by this appendix:

day

This style set provides a color scheme suited for daytime use (light background, dark text). This tag is mutually exclusive with night.

night

This style set provides a color scheme suited for nighttime use (dark background, light text). This tag is mutually exclusive with day.

Examples

Acknowledgements

This draft resulted from discussion in the W3C CSS Working Group and the IDPF EPUB Working Group and would not exist without the particular suggestion of Anne van Kesteren.