W3C

DRAFT: Accessibility Features of CSS

W3C NOTE 9 Mar 1999

This Version:
http://www.w3.org/WAI/EO/NOTE-css-access-19990309
Latest Version:
http://www.w3.org/WAI/EO/NOTE-css-access
Editors:
Ian Jacobs (ij@w3.org)
Judy Brewer (jbrewer@w3.org)

Abstract

This document summarizes the features of the Cascading Style Sheets (CSS), level 2 Recommendation ([CSS2]) known to directly affect the accessibility of Web documents. Some of the accessibility features described in this document were available in CSS1 ([CSS1]) as well. This document has been written so that other documents may refer in a consistent manner to the accessibility features of CSS.

Status of this document

This document is a W3C Note made available by the W3C and the W3C Web Accessibility Initiative. This NOTE has [not yet] been jointly approved by the WAI Education and Outreach Working Group (EOWG) and Protocols and Formats Working Group (PFWG).

Publication of a W3C Note does not imply endorsement by the W3C membership. A list of current W3C technical reports and publications, including working drafts and notes, can be found at http://www.w3.org/TR.

How Style Sheets Benefit Accessibility

CSS benefits accessibility primarily by separating document structure from presentation. Style sheets were designed to allow precise control - outside of markup - of character spacing, text alignment, object position on the page, audio and speech output, font characteristics, etc. By separating style from markup, authors can simplify and clean up the HTML in their documents, making the documents more accessible at the same time.

CSS allows precise control over spacing, alignment and positioning. Authors can thereby avoid "tag misuse" - the practice of misusing a structural element for its expected stylistic effects. For example, while the BLOCKQUOTE and TABLE elements in HTML are meant to mark up quotations and tabular data, they are frequently used to create visual effects instead such as indentation and alignment. When specialized browsing software such as a speech synthesizer encounters elements that are misused in this way, the results can be unintelligible to the user.

In addition to preventing element misuse, style sheets can help reduce image misuse. For instance, authors sometimes use 1-pixel invisible images to position content. This not only bloats documents, making them slow to download, but can also confuse software agents looking for alternative text (the "alt" attribute) for these images. CSS positioning properties mean that invisible images are no longer required to control positioning.

CSS provides precise control over font size, color, and style. Some authors have used images to represent text in a particular font when they are uncertain of the availability of the font on the client's machine. Text in images is not accessible to specialized software such as screen readers, nor can it be cataloged by search robots. To remedy this situation, the powerful WebFonts of CSS allows users much greater control of client-side font information.

CSS allows users to override author styles. This is very important to users who cannot perceive a page with the author's chosen fonts and color. CSS allows users to view documents with their own preferred fonts, colors, etc. by specifying them in a user style sheet.

CSS provides support for automatically generated numbers, markers, and other content that can help users stay oriented within a document. Long lists, tables, or documents are easier to navigate when numbers or other contextual clues are provided in an accessible manner.

CSS supports aural style sheets, which specify how a document will sound when rendered as speech. Aural style sheets (or "ACSS for short") allow authors and users to specify the volume of spoken content, background sounds, spatial properties for sound, and a host of other properties that can add effects to synthesized speech analogous to those achieved with fonts for visual output.

CSS provides more precise control over the display of alternative content than HTML alone. CSS2 selectors give access to attribute values, often used to provide alternative content. In CSS2, attribute values may be rendered in a document along with an element's primary content.

Accessibility features in CSS2

The following is a list of CSS2 features that affect accessibility. Each property (in single quotes) or topic is followed by the section number of the CSS2 specification where it is discussed.

Spacing, alignment, and positioning
'text-indent' (16.1); 'text-align' (16.2); 'word-spacing' and 'letter-spacing' (16.4); 'font-stretch', (15.2.3); 'margin', 'margin-top', 'margin-right', 'margin-bottom', and 'margin-left' (8.3); 'float' (9.5.1), 'position' (9.3.1); 'top', 'right', 'bottom', and 'left' (9.3.2); 'empty-cells' (17.6.1)
User override of styles
!important (6.4.1); the 'inherit' value (6.2.1); system fonts (15.2.5); system colors (18.2); list types (12.6.2); dynamic outlines ('outline', 'outline-width', 'outline-style', and 'outline-color') (18.4)
Generated content
:before/:after pseudo-elements (5.12.3, 12.1); 'content' (12.2); 'cue', 'cue-before', and 'cue-after' (19.5)
Aural style sheets
'volume' (19.2); 'speak' (19.3); 'pause', 'pause-before', and 'pause-after' (19.4); 'cue', 'cue-before', 'cue-after' (19.5); 'play-during' (19.6); 'azimuth', 'elevation' (19.7); 'speech-rate', 'voice-family', 'pitch', 'pitch-range', 'stress', and 'richness' (19.8); 'speak-punctuation' and 'speak-numeral' (19.9)
Access to alternative content
attribute selectors (5.8); the attr() function (12.2)
WebFonts
See Chapter 15 of the CSS2 specification.

Spacing, alignment, and positioning

CSS2 allows authors to control the visual placement of content on the page through text indentation, margins, floats, and absolute and relative positioning. By using CSS properties to achieve visual effects, authors can write simpler HTML and eliminate images and non-breaking spaces ( ) used for positioning.

The following properties give control over spacing, alignment, and positioning:

User override of styles

In order to ensure that users can control styles, CSS2 changes the semantics of the "!important" operator defined in CSS1. In CSS1, authors always had final say over styles. In CSS2, if a user's style sheet contains "!important", it takes precedence over any applicable rule in an author's style sheet. This is indeed an important feature to users who require or must avoid certain color combinations or contrasts, users who require large fonts, etc. For instance, the following rule specifies a large font size for paragraph text and would override an author rule of equal weight:

P { font-size: 24pt ! important }

The CSS2 'inherit' value - available for every property - leads to compact "!important" style rules that govern most or all of a document. For instance, the following style rules force all backgrounds to white and all foreground colors to black:

   /* 
   Sets the text color to black and the background color
   to white for the document body.
   */

BODY { 
      color: black ! important ;  
      background: white ! important 
}

   /* 
   Causes the values of 'color' and 'background'
   to be inherited by all other elements, strengthened
   by !important. Note that this may be overridden
   by other, more specific, user styles.
   */

* { 
      color: inherit ! important ; 
      background: inherit ! important 
}

CSS2 also includes these user control features:

For example, to draw a thick black line around an element when it has the focus, and a thick red line when it is active, the following rules can be used:

      :focus  { outline: thick solid black }
      :active { outline: thick solid red }

Generated content

CSS2 includes several mechanisms that allow content to be generated from style sheets:

Generated content can serve as markers to help users navigate a document and stay oriented when they can't access visual clues such as proportional scrollbars, frames with tables of contents, etc.

For instance, the following user style sheet would cause the words "End Example" to be generated after each example marked up with a special class value in the document:

DIV.example:after { content: End Example }

Users could also, for example, number paragraphs so that they could locate their current reading position in a document:

P:before { content: counter(paragraph) ". " ;
           counter-increment: paragraph }

Aural Cascading Style Sheets

CSS2's aural properties provide information to non-sighted users and voice-browser users much in the same way fonts provide visual information. The following example show how various sound qualities (including 'voice-family', which is something like an audio font) can let a user know that spoken content is a header:

H1 {
    voice-family: paul;
    stress: 20;
    richness: 90;
    cue-before: url("ping.au")
    }

The following properties are part of CSS2's aural cascading style sheets.

Furthermore, the 'speak-header' property describes how table header information is to be spoken before a table cell.

Access to alternative representations of content

CSS2 lets users access alternative representations of content that is specified in attribute values when the following are used together:

In the following example, the value of the "alt" attribute for the IMG element is rendered after the image (visually, aurally, etc.):

IMG:after { content: attr(alt) }

Note that the value of the attribute is displayed even though the image may not be (e.g., the user has turned off images through the user interface).

Media types

The CSS2 "media types" (used with @media rules) allow authors and users to design style sheets that will cause documents to render more appropriately on certain target devices. These style sheets can tailor content for presentation on braille devices,speech synthesizers, or tty devices. Using "@media" rules can also reduce download times by allowing user agents to ignore inapplicable rules.

About the Web Accessibility Initiative

W3C's Web Accessibility Initiative (WAI) addresses accessibility of the Web through five complementary activities that:

  1. Ensure that the technology of the Web supports accessibility
  2. Develop accessibility guidelines
  3. Develop tools to facilitate evaluation and repair of Web sites
  4. Conduct education and outreach
  5. Conduct research and development

WAI's International Program Office enables partnering of industry, disability organizations, accessibility research organizations, and governments interested in creating an accessible Web. WAI sponsors include the US National Science Foundation and Department of Education's National Institute on Disability and Rehabilitation Research; the European Commission's DG XIII Telematics for Disabled and Elderly Programme; IBM, Lotus Development Corporation, and NCR.

Additional information on WAI is available at http://www.w3.org/WAI.

About the WAI Web Accessibility Guidelines

Web accessibility guidelines are essential for Web site development and for Web-related applications development. WAI is coordinating with many organizations to produce three sets of guidelines:

About the World Wide Web Consortium (W3C)

The W3C was created to lead the Web to its full potential by developing common protocols that promote its evolution and ensure its interoperability. It is an international industry consortium jointly run by the MIT Laboratory for Computer Science (LCS) in the USA, the National Institute for Research in Computer Science and Control (INRIA) in France and Keio University in Japan. Services provided by the Consortium include: a repository of information about the World Wide Web for developers and users; reference code implementations to embody and promote standards; and various prototype and sample applications to demonstrate use of new technology. To date, more than 320 organizations are Members of the Consortium. For more information about the World Wide Web Consortium, see http://www.w3.org/

References

A list of current W3C Recommendations and other technical documents can be found at http://www.w3.org/TR.

[CSS2]
"Cascading Style Sheets, level 2", B. Bos, H. W. Lie, C. Lilley, and I. Jacobs, 17 May 1998.
[CSS1]
"Cascading Style Sheets, level 1", H. W. Lie and B. Bos, 17 December 1996. Revised 11 January 1999.
[HTML40]
"HTML 4.0 Recommendation", D. Raggett, A. Le Hors, and I. Jacobs, eds., 18 December 1997, revised 24 April 1998.
[XML10]
"Extensible Markup Language (XML) 1.0.", T. Bray, J. Paoli, C.M. Sperberg-McQueen, eds., 10 February 1998.
[WAI-AUTOOLS]
"Authoring Tool Accessibility Guidelines", J. Treviranus, J. Richards, I. Jacobs, C. McCathieNevile, eds.
[WAI-PAGEAUTH]
"Web Content Accessibility Guidelines", W. Chisholm, G. Vanderheiden, and I. Jacobs, eds.
[WAI-USERAGENT]
"User Agent Accessibility Guidelines", J. Gunderson and I. Jacobs, eds.