Web Content Accessibility Guidelines (WCAG)
repository·main·Indexed 23 days ago
https://github.com/w3c/wcagDevelopment environment and build system for Web Content Accessibility Guidelines (WCAG) 2, including understanding documents and techniques. This repository uses an Eleventy-based build system with Liquid templating and Cheerio to compile specifications. It provides JSON serializations of WCAG 2.1 and 2.2, including principles, guidelines, success criteria, and glossary terms.
What's inside wcag
- This repository is used to develop content for WCAG 2, including the Web Content Accessibility Guidelines, associated understanding documents, and techniques. The project uses an Eleventy-based build system with Liquid templating and Cheerio for transformations to process these documents.
Define situations and groups in the `sufficient` array
mainThe
sufficientarray can contain technique entries or subsection entries (situations).Subsection (Situation) Structure
Subsections are used to define multiple situations (e.g., "Situation A:"). A subsection must contain:
title: Required (HTML allowed).techniques: Required (array of technique entries).note: Optional (HTML allowed).groups: Optional (array of objects withid,title, andtechniques).
Groups within Situations
Defining
groupsautomatically implies a "using" relationship for the techniques within those groups.WCAG repository file structure
mainContent for WCAG 2.1 and later is organized by versioned directories. The
{version}placeholder refers to the WCAG version (e.g.,20for WCAG 2.0,21for WCAG 2.1,22for WCAG 2.2).guidelines/index.html: The main guidelines file.guidelines/sc/{version}/*.html: Individual HTML fragments for each success criterion.guidelines/terms/{version}/*.html: Individual HTML fragments for each definition.understanding/{version}/*.html: Understanding files for each success criterion.
Handle version-specific content in documents
mainWhen working within
techniquesorunderstandingfolders, you can control how version numbers and updates appear in informative documents.Displaying version numbers
Insert
{{ versionDecimal }}to display the decimal-point-delimited version number (e.g., 2.1 or 2.2)."New in {version}" call-outs
To show content only in newer versions with a prefix:
- Apply
class="wcagXY"to the surrounding element (e.g.,class="wcag22"for WCAG 2.2). - The text will be omitted from earlier versions and displayed as
New in WCAG X.Y: [content]in applicable versions.
If you use
class="wcagXY"alongside thenoteclass, the note title will be appended with(New in WCAG X.Y)in applicable versions, and the note will be hidden in earlier versions.- Apply
Structure of a Technique file
mainTechniques are standalone HTML files located in the
techniquesfolder, grouped by technology into sub-folders. Each file must follow a specific structure using top-level<section>elements with the following IDs:meta: Provides context for authoring (removed during publication).applicability: (Recommended) Describes when the technique applies.description: (Required) Explains the technique.examples: (Recommended) Demonstrates the technique.tests: (Required) Provides ways to test the technique.related: (Optional) Links to other techniques.resources: (Optional) Provides additional resources.
The technique title must be placed in an
<h1>element.Note on instructions: Elements with
class="instructions"are used to guide template population. They are ignored by the generator, but you should remove them once the technique is developed. Do not copyclass="instructions"into real content.To use the editor's draft stylesheet, add this to the
<head>:<link rel="stylesheet" type="text/css" href="../../css/editors.css"/>Reference sections and term definitions in errata
mainWhen an erratum relates to a specific section or term, include a link using the
trUrlvariable.- For Success Criteria/Sections: Use the section ID as the fragment.
- For Term Definitions: Use the
dfn-prefix followed by the term name as the fragment.
Example phrasing for a success criterion:
In <a href="{{ trUrl }}#target-size-minimum">2.5.8 Target Size (Minimum)</a>Example phrasing for a term definition:
In the definition for <a href="{{ trUrl }}#dfn-single-pointer">single pointer</a>In <a href="{{ trUrl }}#target-size-minimum">2.5.8 Target Size (Minimum)</a>In the definition for <a href="{{ trUrl }}#dfn-single-pointer">single pointer</a>Usage permissions and attribution for WCAG JSON data
mainYou are permitted to use the WCAG JSON data, in full or in part, under the following conditions:
- Attribution: Clearly attribute the original source and include a link to the relevant WCAG version (e.g., Web Content Accessibility Guidelines (WCAG) 2.2 or Techniques for WCAG 2.2).
- Integrity: Do not change the content.
- Clarity: If you add additional information, you must clearly distinguish between the W3C WCAG content and your own additions.
For more details, refer to the W3C Document license and W3C Intellectual rights.
Access JSON serialization of WCAG 2
mainThe WCAG 2 data is serialized into JSON format and published monthly. This JSON includes Principles, guidelines, success criteria, glossary terms, and associations between normative success criteria and informative techniques. You can access the latest versions at the following URLs:
- WCAG 2.2 JSON:
https://www.w3.org/WAI/WCAG22/wcag.json - WCAG 2.1 JSON:
https://www.w3.org/WAI/WCAG21/wcag.json
- WCAG 2.2 JSON:
Manage WCAG 2.1 and 2.2 errata
mainErrata for WCAG 2.1 and 2.2 are maintained within this repository.
- WCAG 2.1 Edits: Direct edits to the guidelines for WCAG 2.1 must be performed under the
guidelines/directory on theWCAG-2.1branch. - Builds and Main Branch: The errata for both versions are maintained on the
mainbranch for use in builds.
For detailed authoring instructions, refer to the Errata README.
- WCAG 2.1 Edits: Direct edits to the guidelines for WCAG 2.1 must be performed under the
Prepare and edit draft Success Criteria
mainTo contribute a new or updated success criterion (SC), follow these steps:
- Clone the repository:
https://github.com/w3c/wcag.git. - Switch to the proposal's working branch (named using the SC shortname and issue number).
- Locate the SC file in
guidelines/sc/21/(or the appropriate version folder) and any required definitions inguidelines/terms/21/. - Open
guidelines/index.htmland remove the comment marks surrounding the lines referencing your edited SC and terms to include them in the main document. - Format the SC content using the required HTML structure.
- Save and commit the changes. Important: Include the issue number in your commit message starting with a hash (e.g.,
#1). - Inform the chairs when the SC is ready for Working Group review.
- Clone the repository:
Create a new technique using create-techniques.sh
mainNew techniques should be created in a new branch using the
create-techniques.shscript. This automates branch creation, file copying from the template, and setting up themetasection.Command Syntax:
bash create-techniques.sh <technology> <filename> <type> "<title>"Arguments:
<technology>: The technology directory (e.g.,html).<filename>: The temporary filename without extension.<type>: Eithertechniqueorfailure."<title>": The title of the technique, enclosed in quotes with special characters escaped with\.
Create working examples for techniques
mainWorking examples are comprehensive code samples (including full styles, scripts, and images) that demonstrate a technique in action. They are stored in the
working-examplesdirectory.To create a new working example:
- Name the example: e.g., "Using the alt attribute".
- Create a branch: Use a name starting with
example-, e.g.,example-alt-attribute. - Create a directory: Inside
working-examples/, use the semantic name without the prefix, e.g.,working-examples/alt-attribute/. - Name the entry file: Use
index.htmlif the primary example is HTML; otherwise, use a suitable filename. - Manage resources:
- Use relative links for shared resources (e.g.,
../css/example.css). - Shared resources are located in subdirectories like
working-examples/css,working-examples/img, orworking-examples/script. - Place unique resources in the example's own directory (e.g.,
working-examples/alt-attribute/css/alt.css).
- Use relative links for shared resources (e.g.,
- Reference the example: In technique documents, reference the example using a rawgit URI pointing to the development branch (e.g.,
https://rawgit.com/w3c/wcag/main/working-examples/alt-attribute/). - Submit: Once functional, submit a pull request to the
mainbranch.