Copyright © 2017 . This document is available under the W3C Document License. See the W3C Intellectual Rights Notice and Legal Disclaimers for additional information.
Alternate Style Tags defines a pattern for tagging alternate style sheets using a microformat
This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications can be found in the W3C technical reports index at https://www.w3.org/TR/.
By publishing this document, W3C acknowledges that the Submitting Members have made a formal Submission request to W3C for discussion. Publication of this document by W3C indicates no endorsement of its content by W3C, nor that W3C has, is, or will be allocating any resources to the issues addressed by it. This document is not the product of a chartered W3C group, but is published as potential input to the W3C Process. A W3C Team Comment has been published in conjunction with this Member Submission. Publication of acknowledged Member Submissions at the W3C site is one of the benefits of W3C Membership. Please consult the requirements associated with Member Submissions of section 3.3 of the W3C Patent Policy. Please consult the complete list of acknowledged W3C Member Submissions.
This section is non-normative.
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.
HTML 4.0 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] 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], 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.
As well as sections marked as non-normative, all authoring guidelines, diagrams, examples, and notes in this specification are non-normative. Everything else in this specification is normative.
The key words MAY, MUST, MUST NOT, OPTIONAL, RECOMMENDED, REQUIRED, SHALL, SHALL NOT, SHOULD, and SHOULD NOT are to be interpreted as described in [RFC2119].
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.
This section is non-normative.
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
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
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
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].
A style sheet can be tagged by adding the tag's name to the
class attribute of the
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.
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.
[HTML] HTML .
[HTML401] HTML 4.01 Specification . 24 December 1999.
[RFC2119] Key words for use in RFCs to Indicate Requirement Levels (RFC 2119) . March 1997.
[CSSOM] CSSOM .