Please use this branch as the target for pull requests until July 10, 2016.
This repository is used to develop content for WCAG 2, as well as associated understanding documents and techniques.
@@To complete
See also: WCAG 2 Style Guide
WCAG 2.0 was maintained in a different file structure than subsequent versions of WCAG. Source files for WCAG 2.0 are in the wcag20 folder and exists primarily for archival purposes. Do not edit content in that folder.
Content for WCAG 2.1 and later is organized according to the file structure below. The WCAG repository contains source and auxiliary files for WCAG 2, Understanding WCAG 2, and eventually techniques. It also contains auxiliary files that support automated formatting of the document. To facilitate multi-party editing, each success criterion is in a separate file, consisting of a HTML fragment that can be included into the main guidelines. Key files include:
guidelines/index.html
- the main guidelines fileguidelines/sc/{version}/*.html
- files for each success criterionguidelines/terms/{version}/*.html
- files for each definitionunderstanding/{version}/*.html
- understanding files for each success criterionWhere {version}
is "20", content came from WCAG 2.0. "21" is used for content introduced in WCAG 2.1, "22" for WCAG 2.2, etc.
Success Criteria Managers will prepare candidate success criteria, ready for inclusion in the guidelines document. To prepare success criteria, follow these steps:
#1
. Success criteria use a simple structure of HTML elements, with a few class attribute values, to ensure consistency. Enhancement scripts and style key off this structure. Content you provide is indicated in braces. Items after comments are optional.
<section class="sc">
<h4>{SC Handle}</h4>
<p class="conformance-level">{Level}</p>
<p class="change">{Change}</p>
<p>{Main SC Text}</p>
<!-- if SC has sub-points -->
<dl>
<dt>{Point Handle}</dt>
<dd>{Point Text}</dd>
</dl>
<!-- if SC has notes -->
<p class="note">{Note}</p>
</section>
Note you do not provide the SC number. Numbers will be assigned, and most likely automatically generated, later.
Values you provide are described below. Refer to Success Criterion 2.2.1 for an example of each of these pieces of content.
`elements may be provided.
If you are providing term definitions along with your SC, include them in the respective guidelines/terms/{version}
directory, one-per-file, using the following format:
<dt><dfn id="dfn-{shortname}">{Term}</dfn></dt>
<dd>{Definition}</dd>
The dfn
element tells the script that this is a term and causes special styling and linking features. To link to a term, use an <a>
element without an href
attribute; if the link text is the same as the term, the link will be correctly generated. For example, if there is a term <dfn>web page</dfn>
on the page, a link in the form of <a>web page</a>
will result in a proper link.
If the link text has a different form from the canonical term, e.g., "web pages" (note the plural), you can provide a hint on the term definition with the data-lt
attribute. In this example, modify the term to be <dfn data-lt="web pages">web page</dfn>
. Multiple alternate names for the term can be separated with pipe characters, with no leading or trailing space, e.g., <dfn data-lt="web pages|page|pages">web page</dfn>
.
There is one Understanding file per success criterion, plus an index:
understanding/index.html
- index page, need to uncomment or add a reference to individual Understanding pages as they are made availableunderstanding/{version}/*.html
- files for each understanding page, named the same as the success criterion file in the guidelinesFiles are populated with a template that provides the expected structure. Leave the template structure in place, and add content as appropriate within the sections. Elements with class="instructions" provide guidance about what content to include in that section; you can remove those elements if you want but don't have to. The template for examples proposes either a bullet list or a series of sub-sections, choose one of those approaches and remove the other from the template. The template for techniques includes sub-sections for "situations", remove that wrapper section if not needed.
Understanding files are referenced from the relevant Success Criterion on the WCAG specification; these links are put in by the script.
The formal publication location for Understanding pages is currently https://www.w3.org/WAI/WCAG21/Understanding/. This content is updated as needed; and may be automated.
Techniques are in the techniques folder, and grouped by technology into sub-folders. Each technique is a standalone file, which is in HTML format with a regular structure of elements, classes, and ids.
The technique template shows the structure of techniques. Main sections are in top-level <section> elements with specific IDs: meta, applicability, description, examples, tests, related, resources. The description and tests sections are required; the applicability and examples sections are recommended; the related and resources sections are optional. The meta section provides context for the technique during authoring but is removed for publication. The title of the technique is in the <h1>
element. Elements with class="instructions"
provide information about populating the template. They should be removed as the technique is developed but if not removed, will be ignored by the generator. Do not copy class="instructions"
on real content.
Techniques can use a temporary style sheet to facilitate review of drafts. This style sheet is replaced by other style sheets and structure for formal publication. To use this style sheet, add <link rel="stylesheet" type="text/css" href="https://github.com/w3c/wcag/blob/main/./../css/editors.css"/>
to the head of the technique.
Techniques can include images. Place the image file in the img
folder of the relevant technology - meaning all techniques for a technology share a common set of images. Use a relative link to load the image. Most images should be loaded with a <figure>
element and labeled with a <figcaption>
positioned at the bottom of the figure. <figure>
elements must have an id
attribute. Small inline images may be loaded with a <img>
element with suitable alt
text.
Techniques should include brief code examples to demonstrate how to author content that follows the technique. Code examples should be easy to read, and usually not complete content in themselves. More complete examples can be provided as working examples (see below). Link to working examples at the bottom of each example, in a <p class="working-example">
element, containing a relative link to ../../working-examples/{example-name}/
.
Cross references to other techniques may be provided where useful. Generally they should be provided in the "Related Techniques" section but can be provided elsewhere. Use a relative link to reference the technique, {Technique ID}
if the same technology, or ../{Technology}/{Technique ID}
otherwise. If the technique is still under development and does not have a formal ID, reference the path to the development file. If the technique is under development in a different branch, use an absolute URI to the rawgit version of the technique.
Cross references to guidelines and success criteria should use a relative URI to the Understanding page for that item. Cross references to other parts of the guidelines should use an absolute URI to the guidelines as published on the W3C TR page, a URI beginning with https://www.w3.org/TR/WCAG21/#
. Note that references to guidelines or success criteria to which techniques relate are added by the generator upon publication based on information in the Understanding documents, so redundant links to those is not normally needed or advised.
General priorities and process to work on techniques are maintained in the wiki.
New techniques should use a filename that is derived from a shortened version of the technique title. Editors will assign the technique an ID and rename the file when it is accepted by the Working Group. For example, a technique "Using the alt attribute on the img element to provide short text alternatives" might use "img-alt-short-text-alternatives.html" as the filename. The editors will assign it a formal ID, and rename the file, when it is accepted by the Working Group.
Each new technique should be created in a new branch. Set-up of the branch and file is automated via the create-techniques.sh script, which can be run with bash. The command line is:
bash create-techniques.sh <technology> <filename> <type> "<title>"
<technology>
is the technology directory for the technique<filename>
is the temporary filename (without extension) for the technique<type>
is "technique" or "failure"<title>
is the title of the technique, enclosed in quotes and escaping special characters with \This automates the following steps:
Once a technique branch and file is set up, populate the content and request review:
Techniques in the repository are plain HTML files with minimal formatting. For publication to the editors' draft and W3C location, techniques are formatted by a build process based on Eleventy for templating and Cheerio for transformations. More details, including instructions for previewing locally, can be found in the build process README.
The generator compiles the techniques together as a suite with formatting and navigation. It enforces certain structures, such as ordering top-level sections described above and standardizing headings. It attempts to process cross reference links to make sure the URIs work upon publication. One of the most substantial roles is to populate the Applicability section with references to the guidelines or success criteria to which the technique relates. The information for this comes from the Understanding documents. Proper use of the technique template is important to enable this functionality, and mal-formed techniques may cause the generator to fail.
Obsolete techniques should not be removed from the repository. Instead, they can be marked using YAML front-matter. For example:
---
obsoleteSince: 22
obsoleteMessage: |
This failure relates to 4.1.1: Parsing, which was removed as of WCAG 2.2.
---
obsoleteSince
indicates the earliest version of WCAG 2 when the technique became obsolete
(this may be set to 20
if it should effectively be obsolete for all versions, e.g. for
techniques involving deprecated HTML elements)obsoleteMessage
indicates a message to be displayed within the About this Technique sectionIn cases where entire technologies are obsolete (e.g. Flash and Silverlight), these properties may also be specified at the technique subdirectory level, e.g. via techniques/flash/flash.11tydata.json
.
Note that this case specifically requires JSON format, as this is consumed by both Eleventy and additional code in the build process used to assemble techniques data.
Informative documents are generated from the same source files for both WCAG 2.2 and 2.1,
as most of their content is consistent between them. (The guidelines themselves continue to be
maintained on separate branches e.g. WCAG-2.1
, for purposes of maintaining separate Editors' Drafts.)
When building informative documents for older versions, the build system prunes success criteria that are specific to newer versions, and in turn any techniques that are exclusively related to those criteria.
There are a few cases where content may need to cater to a specific version, explained in this section.
Note: This is only applicable within techniques
and understanding
folders (not guidelines
).
In cases where the precise version number should be displayed within informative documents,
insert {{ versionDecimal }}
. This will be replaced with the decimal-point-delimited version number,
e.g. 2.1 or 2.2.
In cases where a document pertaining to multiple versions warrants a specific call-out about an update in
a newer version, class="wcagXY"
can be applied to an element surrounding the prose in question
(e.g. class="wcag22"
for WCAG 2.2). This will result in the prose being omitted from earlier versions,
and displayed with the prefix "New in WCAG X.Y: " in applicable versions.
This class can also be applied alongside the note
class, in which case " (New in WCAG X.Y)" will be
appended to the "Note" title in applicable versions, and the note will be hidden in earlier versions.
At the time of writing (November 2024), the Change Log in the Techniques index is identical between WCAG 2.1 and 2.2.
These have been split out into separate version-specific includes under _includes/techniques/changelog/*.html
for future-proofing in support of building multiple versions of informative documents from the same branch.
Examples in techniques should be brief easy-to-consume code samples of how the technique is used in content. Therefore examples should focus on the specific features the technique describes, and not include related content such as style, script, surrounding web content, etc.
Often it is desirable to provide more comprehensive examples, which show the technique in action while not interfering with the main technique document. These examples also show the complete code required to make the technique operate, including full style and script files, images, page code, etc. Usually, these "working examples" are referenced at the bottom of the elided example which is included in the main technique.
Working examples are stored in the working-examples
directory of the repository. Each example is in its own subdirectory, to contain the multiple files that may be necessary to make the example work. In some cases, multiple working examples will share common resources; these are stored in the appropriate sub-directory of the working-examples directory, e.g., working-examples/css
, working-examples/img
, working-examples/script
. Reference these common resources when available; otherwise place resources in the working example directory, using subdirectories to organize when appropriate.
To create a working example:
example-
and which otherwise semantically identifies the example, e.g., example-alt-attribute
.working-examples/alt-attribute/
.index.html
. Otherwise, create a suitable file name.../css/example.css
. Place other resources in the same directory as the main example, e.g., working-examples/alt-attribute/css/alt.css
.https://rawgit.com/w3c/wcag/main/working-examples/alt-attribute/
. Editors will update links when examples are approved.WCAG 2.2 is ready for translation. To translate WCAG 2.2, follow instructions at How to Translate WCAG 2.