Web Content Accessibility Guidelines (WCAG)

repository·main·Indexed 23 days ago

https://github.com/w3c/wcag

Development 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.

Tokens
5.9K
Snippets
10
Records
33
Agent score
79%

What's inside wcag

  1. Overview of the WCAG repository

    main
    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.
  2. Define situations and groups in the `sufficient` array

    main

    The sufficient array 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 with id, title, and techniques).

    Groups within Situations

    Defining groups automatically implies a "using" relationship for the techniques within those groups.

  3. WCAG repository file structure

    main

    Content for WCAG 2.1 and later is organized by versioned directories. The {version} placeholder refers to the WCAG version (e.g., 20 for WCAG 2.0, 21 for WCAG 2.1, 22 for 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.
  4. Handle version-specific content in documents

    main

    When working within techniques or understanding folders, 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:

    1. Apply class="wcagXY" to the surrounding element (e.g., class="wcag22" for WCAG 2.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 the note class, the note title will be appended with (New in WCAG X.Y) in applicable versions, and the note will be hidden in earlier versions.

  5. Structure of a Technique file

    main

    Techniques are standalone HTML files located in the techniques folder, 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 copy class="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"/>

  6. Reference sections and term definitions in errata

    main

    When an erratum relates to a specific section or term, include a link using the trUrl variable.

    • 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>
  7. Usage permissions and attribution for WCAG JSON data

    main

    You are permitted to use the WCAG JSON data, in full or in part, under the following conditions:

    1. 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).
    2. Integrity: Do not change the content.
    3. 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.

  8. Access JSON serialization of WCAG 2

    main

    The 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
  9. Manage WCAG 2.1 and 2.2 errata

    main

    Errata 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 the WCAG-2.1 branch.
    • Builds and Main Branch: The errata for both versions are maintained on the main branch for use in builds.

    For detailed authoring instructions, refer to the Errata README.

  10. Prepare and edit draft Success Criteria

    main

    To contribute a new or updated success criterion (SC), follow these steps:

    1. Clone the repository: https://github.com/w3c/wcag.git.
    2. Switch to the proposal's working branch (named using the SC shortname and issue number).
    3. Locate the SC file in guidelines/sc/21/ (or the appropriate version folder) and any required definitions in guidelines/terms/21/.
    4. Open guidelines/index.html and remove the comment marks surrounding the lines referencing your edited SC and terms to include them in the main document.
    5. Format the SC content using the required HTML structure.
    6. Save and commit the changes. Important: Include the issue number in your commit message starting with a hash (e.g., #1).
    7. Inform the chairs when the SC is ready for Working Group review.
  11. Create a new technique using create-techniques.sh

    main

    New techniques should be created in a new branch using the create-techniques.sh script. This automates branch creation, file copying from the template, and setting up the meta section.

    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>: Either technique or failure.
    • "<title>": The title of the technique, enclosed in quotes with special characters escaped with \.
  12. Create working examples for techniques

    main

    Working examples are comprehensive code samples (including full styles, scripts, and images) that demonstrate a technique in action. They are stored in the working-examples directory.

    To create a new working example:

    1. Name the example: e.g., "Using the alt attribute".
    2. Create a branch: Use a name starting with example-, e.g., example-alt-attribute.
    3. Create a directory: Inside working-examples/, use the semantic name without the prefix, e.g., working-examples/alt-attribute/.
    4. Name the entry file: Use index.html if the primary example is HTML; otherwise, use a suitable filename.
    5. 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, or working-examples/script.
      • Place unique resources in the example's own directory (e.g., working-examples/alt-attribute/css/alt.css).
    6. 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/).
    7. Submit: Once functional, submit a pull request to the main branch.