text
stringlengths 153
62.8k
|
|---|
Contributions to this repository are intended to become part of Recommendation-track documents governed by the
[W3C Patent Policy](https://www.w3.org/Consortium/Patent-Policy-20040205/) and
[Document License](https://www.w3.org/Consortium/Legal/copyright-documents). To make substantive contributions to specifications, you must either participate
in the relevant W3C Working Group or make a non-member patent licensing commitment.
If you are not the sole contributor to a contribution (pull request), please identify all
contributors in the pull request comment.
To add a contributor (other than yourself, that's automatic), mark them one per line as follows:
```
+@github_username
```
If you added a contributor by mistake, you can remove them in a comment with:
```
-@github_username
```
If you are making a pull request on behalf of someone else but you had no part in designing the
feature, you can remove yourself with the above syntax.
Public comments can be made by opening a new Issue https://github.com/w3c/wcag/issues/new. The public can also comment on any issue threads on Github https://github.com/w3c/wcag/issues.
|
All documents in this Repository are licensed by contributors
under the
[W3C Document License](https://www.w3.org/Consortium/Legal/copyright-documents).
|
WCAG (Web Content Accessibility Guidelines) 2
===
This repository is used to develop content for WCAG 2, as well as associated understanding documents and techniques.
See [Onboarding for working in Github](https://www.w3.org/WAI/GL/wiki/Onboarding_for_working_in_Github)
## Editorial style guide
@@To complete
* Avoid use of RFC2119 terms such as "must", "shall", or "may" in non-normative content, to avoid confusion with normative role.
See also: [WCAG 2 Style Guide](https://github.com/w3c/wcag/wiki/WCAG-2-style-guide)
## File Structure
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 file
* `guidelines/sc/{version}/*.html` - files for each success criterion
* `guidelines/terms/{version}/*.html` - files for each definition
* `understanding/{version}/*.html` - understanding files for each success criterion
* `wcag20/` was used by a previous version of WCAG, so anything ending .xml is no longer used, *do not update*.
Where `{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.
## Build System
The Techniques and Understanding documents are processed through a build system based on Eleventy and Liquid for templating and Cheerio for transformations.
More details, including instructions for previewing the output locally, can be found in the [build process README](11ty/README.md).
## Editing Draft Success Criteria
[Success Criteria Managers](https://www.w3.org/WAI/GL/wiki/SC_Managers_Phase1) will prepare candidate success criteria, ready for inclusion in the guidelines document. To prepare success criteria, follow these steps:
1. [Clone the repository](https://help.github.com/articles/cloning-a-repository/), using the URI https://github.com/w3c/wcag.git to clone.
1. Switch to the working branch for the proposal, which is named for the shortname of the draft success criterion and the issue number, concatenated together.
1. Find the appropriate file for the success criterion in the guidelines/sc/21 folder, named the same as the start of the branch name, and open in an HTML-capable editor. Do the same with any definitions referenced by the success criterion, in the guidelines/terms/21 folder.
1. Open the guidelines/index.html file and remove comment marks around the lines that reference the success criterion and terms you have edited..
1. Follow the [success criteria format](#user-content-success-criteria-format) below to create the SC content.
1. Save the file and commit the change. NOTE: It is important to also add a suitable 'commit message'. In the comments, reference the issue number from which the proposal was developed starting with a hash, e.g., `#1`.
1. When the success criterion is ready for Working Group review, inform the chairs. Once the proposal has been accepted by the Working Group, the editors will merge the working branch into the main branch, which puts it in the editors' draft and eventual Technical Report publication.
### Success Criteria Format
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.
```html
<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](https://www.w3.org/TR/WCAG20/#time-limits-required-behaviors) for an example of each of these pieces of content.
<dl>
<dt>{SC Handle}</dt>
<dd>The short name of the SC. In SC 2.2.1 this is "Timing Adjustable".</dd>
<dt>{Level}</dt>
<dd>The conformance level of the SC. Values can be "A", "AA", or "AAA". Do not include the word "Level".</dd>
<dt>{Change}</dt>
<dd>Indicate whether the SC is unchanged from WCAG 2.0, changed, or new. Values can be "Unchanged", "Changed", or "New".</dd>
<dt>{Main SC Text}</dt>
<dd>The main text of the SC, or the starting paragraph. In SC 2.2.1 this is the content that begins "For each time limit...".</dd>
<dt>{Point Handle}</dt>
<dd>If the SC has bullets, each bullet has a handle. In SC 2.2.1 the first bullet point handle is "Turn off".</dd>
<dt>{Point Text}</dt>
<dd>The content of the bullet. In SC 2.2.1 the first bullet point text begins "The user is allowed...".</dd>
<dt>{Note}</dt>
<dd>If there is a note to the SC, provide it after the other content (without the starter "Note"). In SC 2.2.1, this is the content that begins "This success criterion...". If there is more than one note, multiple `<p class="note">`elements may be provided.</dd>
</dl>
### Definitions
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:
```html
<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>`.
## Editing Draft Understanding Content
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 available
* `understanding/{version}/*.html` - files for each understanding page, named the same as the success criterion file in the guidelines
Files 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.
Note that associated techniques are no longer defined within each understanding page; they are now defined in the `associatedTechniques` field in `understanding/understanding.11tydata.js`. See [Associated Techniques Data](11ty/README.md#associated-techniques-data) for more information.
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/WCAG22/Understanding/. This content is updated as needed; and may be automated.
## Editing Techniques
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.
### Technique File Structure
The [technique template](techniques/technique-template.html) 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="../../css/editors.css"/>` to the head of the technique.
### Images, Examples, Cross References for Techniques
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](#user-content-provide-working-examples-of-techniques) (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/WCAG22/#`. 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.
### Create Techniques
[General priorities and process to work on techniques are maintained in the wiki](https://www.w3.org/WAI/GL/wiki/Wcag21-techniques).
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:
* Determine a filename for the technique that is likely to be descriptive, unique, and short.
* Create a working branch named the same as the technique filename.
* Copy the techniques/technique-template.html file into the appropriate technology folder for the technique, and give it the chosen file name.
* In the section element with id "meta", indicate to which guideline or success criterion the technique relates, and whether the technique is sufficient, advisory, or a failure for that item. Multiple applicability are allowed.
Once a technique branch and file is set up, populate the content and request review:
* Populate the template with appropriate content, using other techniques as examples for code formatting choices. Keep the existing structural sections from the template in place.
* When the technique is ready for review, make a pull request into the main branch.
* If you wish to reference the draft technique from an Understanding document, use the technique's rawgit URI.
* After a technique is approved, the chairs will assign it an ID and update links to it in the Understanding documents.
### Formatting Techniques
Techniques in the repository are plain HTML files with minimal formatting. For publication to the editors' draft and W3C location, techniques are formatted by the Eleventy build process described above in the [Build System section](#build-system).
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
Obsolete techniques should not be removed from the repository. Instead, they can be marked using YAML front-matter. For example:
```yaml
---
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 section
In 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.
## Spell-checking
Both the normative and informative content is checked for spelling errors using [cspell](https://cspell.org/). This check runs on pull requests, and can be run locally via `npm run cspell` (requires [Node.js](https://nodejs.org/); remember to run `npm i` first if you haven't recently).
### Adding valid words
If a word is flagged that should be allowed anywhere it appears, add a line to the top-level `custom-words.txt` file, ideally under the appropriate section in alphabetical order.
If a word is flagged that should be allowed in a specific file, but should be considered incorrect elsewhere, add an entry to the `overrides` list in the top-level `cspell.yml` file. (Several examples already exist for reference.)
Note that both inline code and code blocks are ignored, so if you are using a term that pertains to a specific language/syntax, consider enclosing it in `<code>` or `<pre>` as appropriate.
## Version-specific Documentation
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.
### Specifying Precise Version Number within Informative Documents
**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.
### "New in {version}" Call-outs
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.
### Techniques Change Log
Data for the Techniques Change Log is now generated automatically by a script that reads git history;
see [Eleventy Usage](11ty/README.md#usage).
## Working Examples
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:
* Identify the name for the example, e.g., "Using the alt attribute".
* Create a working branch for the example, whose name begins with the prefix `example-` and which otherwise semantically identifies the example, e.g., `example-alt-attribute`.
* Create a directory for the example inside the working examples directory, using the semantic name for the example minus the prefix used in the branch name, e.g., `working-examples/alt-attribute/`.
* If the primary example is HTML, name the file `index.html`. Otherwise, create a suitable file name.
* Refer to resources shared among multiple examples using relative links, e.g., `../css/example.css`. Place other resources in the same directory as the main example, e.g., `working-examples/alt-attribute/css/alt.css`.
* Reference working examples from techniques using the rawgit URI to the example in its development branch, e.g., `https://rawgit.com/w3c/wcag/main/working-examples/alt-attribute/`. Editors will update links when examples are approved.
* When the example is complete and functional, submit a pull request into the main branch.
## Errata
The errata documents for WCAG 2.1 and 2.2 are now maintained in this repository.
See the [Errata README](errata/README.md) for authoring details.
**Note:** The errata for both versions are maintained on the `main` branch for use in builds.
Direct edits to the guidelines for WCAG 2.1 must be performed under `guidelines/` on the `WCAG-2.1` branch.
## Translations
WCAG 2.2 is ready for translation. To translate WCAG 2.2, follow instructions at [How to Translate WCAG 2](https://www.w3.org/WAI/about/translating/wcag/).
|
# Code of Conduct
All documentation, code and communication under this repository are covered by the [W3C Code of Ethics and Professional Conduct](https://www.w3.org/Consortium/cepc/).
|
# Errata Editing Instructions
Errata are listed in reverse-chronological order, first sectioned by publish date,
then within each section based on when each erratum was added.
## Sections
The first top-level section under `<main>` corresponds to the latest version / unpinned URL;
subsequent sections correspond to previous versions / date-stamped URLs.
Each top-level section should be preceded by `trDate` and `trUrl` variable assignments.
These variables reduce the chance of copy-paste errors within individual errata.
For sections corresponding to previous versions, assignments should follow this pattern
(only `YYYY-MM-DD` should need to be replaced):
```
{%- assign trDate = "YYYY-MM-DD" -%}
{%- capture trUrl -%}
https://www.w3.org/TR/{{ trDate | split: "-" | first }}/REC-WCAG{{ page.fileSlug }}-{{ trDate | replace: "-", "" }}/
{%- endcapture -%}
```
The level 2 heading in the top-level section for each previous version should use this code
(no replacements necessary, making use of the preceding variable reassignments):
```html
<h2>Errata since <a href="{{ trUrl }}">{{ trDate | date: "%d %B %Y" }} Publication</a></h2>
```
## Erratum format
Each erratum should be in the following format
(replacing `YYYY-MM-DD`, `Section Title`, `sectionid`, `details of changes`, and `#NNNN`):
```html
<li>
YYYY-MM-DD:
In <a href="{{ trUrl }}#sectionid">Section Title</a>,
details of changes.
({% gh #NNNN %})
</li>
```
Adhering to this format is important, as any entries under the latest published version will also be
parsed for inclusion within Guideline/SC boxes and Key Terms definitions within Understanding pages.
(Newlines are insignificant and are suggested for source code readability.)
Each piece of this format is further explained in the subsections below.
### Section reference
When applicable, errata should begin with an indication of the section they relate to, including a link.
Example phrasing when linking to a section, e.g. a success criterion:
```html
In <a href="{{ trUrl }}#target-size-minimum">2.5.8 Target Size (Minimum)</a>
```
Example phrasing when linking to a term definition:
```html
In the definition for <a href="{{ trUrl }}#dfn-single-pointer">single pointer</a>
```
(Remember that term definition fragments always begin with `dfn-`.)
It is possible to reference multiple sections/terms from one erratum,
so long as all of the links remain front-loaded prior to the erratum's details.
### Details of changes
`details of what happened` should be expressed in present progressive tense
(e.g. "updating", "removing", "adding"), with the desired outcome listed first.
For example:
- updating the red threshold from ... to ...
- removing one note and adding two new notes, including ...
- removing a supernumerary "Note" indicator from the first note.
- correcting the word ... to ...
### GitHub PR or commit
When possible, provide a reference to one or more GitHub pull requests or commit hashes
at the end of each erratum, in the format `({% gh "..." %})`.
The format breaks down as follows:
- `{% gh "..." %}` is a custom shortcode, which accepts one of the following:
- A PR number prefixed with `#`, e.g. `"#4080"` (this is the preferred option when available)
- A commit hash of 7 or more characters, with no prefix, e.g. `"b043430"`
- The quotes around the parameter passed to the `gh` shortcode are necessary for template parsing
- The outer parentheses exist only for punctuation, and are directly output
|
# Eleventy Infrastructure for WCAG Techniques and Understanding
This subdirectory contains ES Modules re-implementing pieces of the
XSLT-based build process using Eleventy.
## Usage
Make sure you have Node.js installed. This has primarily been tested with v20,
the current LTS at time of writing.
If you use [`fnm`](https://github.com/Schniz/fnm) or [`nvm`](https://github.com/nvm-sh/nvm) to manage multiple Node.js versions,
you can switch to the recommended version by typing `fnm use` or `nvm use`
(with no additional arguments) while in the repository directory.
Otherwise, you can download an installer from [nodejs.org](https://nodejs.org/).
First, run `npm i` in the root directory of the repository to install dependencies.
Common tasks:
- `npm run build` runs a one-time build
- `npm start` runs a local server with hot-reloading to preview changes as you make them:
- http://localhost:8080/techniques
- http://localhost:8080/understanding
Maintenance tasks (for working with Eleventy config and supporting files used by the build):
- `npm run check` checks for TypeScript errors
- `npm run fmt` formats all TypeScript files
## Publishing to WAI website
The following npm scripts can be used to assist with publishing updates to the WAI website:
- `npm run publish-w3c` to publish 2.2
- `npm run publish-w3c:21` to publish 2.1
Each of these scripts performs the following steps:
1. Updates the data used for the Techniques Change Log page
- Note that this step may result in changes to `techniques/changelog.11tydata.json`, which should be committed to `main`
2. Runs the build for the appropriate WCAG version, generating pages and `wcag.json` under `_site`
3. Copies the built files from `_site` to the CVS checkout (see [`WCAG_CVSDIR`](#wcag_cvsdir))
## Associated Techniques Data
Each success criterion's page contains a Techniques section which links to associated techniques.
These used to be defined directly in HTML in each respective page, but have since been relocated to
a single data file, `understanding/understanding.11tydata.js`, under the key `associatedTechniques`.
This field is typed, in order to provide some degree of autocomplete in IDEs that support TypeScript
(e.g. Visual Studio Code), as well as some amount of immediate feedback while editing.
Further validation is performed when running the build or dev server, to provide more focused error messages for common mistakes.
### Listing Techniques
Techniques may be indicated via an object as outlined below, or using a shorthand string.
Shorthand strings may function as either `id` or `title` seen below, and are
recommended for brevity when no `using` or `and` relationship is present.
The following list outlines properties available on each technique object:
- `id` - Technique ID
- `title` - Technique description (HTML flow content allowed), to define free-form entries that don't reference a specific technique
- `using` - Optional array of further techniques to be populated into a child list
- Child techniques may also include `using`
- `usingConjunction` - When `using` is specified, this overrides the word that appears before `usingQuantity`
- Default: `"using"`; HTML flow content allowed
- `usingQuantity` - When `using` is specified, this overrides the word that appears after `usingConjunction` and before "of the following techniques"
- Default: `"one"`
- May be empty string (`""`), in which case the subsequent "of" is dropped
- `usingPrefix` - Adds text to appear before `usingConjunction`
- `skipUsingPhrase` - Omits the entire "... using ... of the following techniques" phrase
- This is mainly an escape hatch for rare instances where a child list is used but no "using" phrase appears at all (e.g. in 1.4.4: Resize Text)
Typically, either `id` or `title` is required.
If `id` is specified, then `prefix` and/or `suffix` may also be specified (with HTML flow content allowed in each),
resulting in "{prefix} {linked technique title} {suffix}".
In extremely rare cases, `using` may be specified alone without either `id` or `title`,
e.g. for top-level "Using two or more of the following" in 2.4.5: Multiple Ways.
#### Conjunctions
To represent multiple parallel techniques, an `and` key may be specified instead of `id` or `title`. In this case, the following properties are supported:
- `and` - an array of technique objects or shorthand strings (as described above)
- `using` and its related fields (seen above) may optionally be specified alongside `and`
- `andConjunction` may optionally be specified alongside `and`,
to override the default `"<strong>AND</strong>"` phrasing (e.g. in 4.1.3: Status Messages)
- Techniques listed _within_ `and` should be flat, never containing `and` or `using`
### Situations or Other Subsections (Sufficient only)
The top level of the `sufficient` array may consist entirely of either technique entries (see above)
or subsection entries. It should not contain a mix of both.
Subsections are typically used to define multiple "situations", where each title begins with "Situation A:", "Situation B:", etc.;
in rare cases it is used for other purposes, e.g. in 1.4.8: Visual Presentation.
Subsection entries contain the following:
- `title` (required, HTML allowed)
- `techniques` (required) - array of technique entries (see above)
- `note` (optional, HTML allowed) - content to appear in a Note at the end of the subsection (e.g. in 4.1.3: Status Messages)
- `groups` (optional) - array of objects with `id`, `title`, `techniques`; see more below
- `techniques` within `groups` are not expected to involve `and` or `using`
#### Groups within Situations
Most of the situations in 1.1.1: Non-text Content include groupings which start with a boldface paragraph (not a heading),
and are referenced one or more times within preceding "using" clauses.
Groups can be defined at the top level of each situation/section entry as mentioned above.
Defining `groups` automatically implies a "using" relationship, without explicitly defining `using` for each technique.
## Environment Variables
### `WCAG_CVSDIR`
**Usage context:** `publish-w3c` script only
Indicates top-level path of W3C CVS checkout, for WAI site updates (via `publish-w3c` script).
**Default:** `../../../w3ccvs` (same as in Ant/XSLT build process)
### `WCAG_VERBOSE`
**Usage context:** Local development, debugging
Prints more log messages that are typically noisy and uninteresting,
but may be useful if you're not seeing what you expect in the output files.
**Default:** Unset (set to any non-empty value to enable)
### `WCAG_VERSION`
**Usage context:** for building informative docs pinned to a publication version
Indicates WCAG version being built, in `XY` format (i.e. no `.`).
Influences which pages get included, guideline/SC content,
and a few details within pages (e.g. titles/URLs, "New in ..." content).
Also influences base URLs for links to guidelines, techniques, and understanding pages.
Explicitly setting this causes the build to reference guidelines and acknowledgements
published under `w3.org/TR/WCAG{version}`, rather than using the local checkout
(which is effectively the 2.2 Editors' Draft). Note this behavior can be further
altered by `WCAG_FORCE_LOCAL_GUIDELINES`.
Possible values: `22`, `21`
### `WCAG_FORCE_LOCAL_GUIDELINES`
**Usage context:** Only applicable when `WCAG_VERSION` is also set;
should not need to be set manually
When building against a fixed publication version, this overrides the behavior of
loading data from published guidelines, to instead load an alternative local
`guidelines/index.html` (e.g. from a separate git checkout of another branch).
This was implemented to enable preview builds of pull requests targeting the
`WCAG-2.1` branch while reusing the existing build process from `main`.
Possible values: A path relative to the project root, e.g. `../guidelines/index.html`
### `WCAG_MODE`
**Usage context:** should not need to be set manually except in specific testing scenarios
Influences base URLs for links to guidelines, techniques, and understanding pages.
Typically set by specific npm scripts or CI processes.
Note that setting `WCAG_MODE` to any non-empty value (even one not listed below) will also result
in page footers referencing last modified times based on git, rather than the local filesystem.
Possible values:
- Unset **(default)** - Sets base URLs appropriate for local testing
- `editors` - Sets base URLs appropriate for `gh-pages` publishing; used by deploy action
- `publication` - Sets base URLs appropriate for WAI site publishing; used by `publish-w3c` script
### `WCAG_JSON`
Generates `_site/wcag.json`. (This is not done by default, as it adds to build time.)
**Default:** Unset by default; `publish-w3c` scripts set this to a non-empty value.
For more information on the output, see [11ty/json/README.md](json#readme).
### `GITHUB_REPOSITORY`
**Usage context:** Automatically set during GitHub workflows; should not need to be set manually
Influences base URLs for links to guidelines, techniques, and understanding pages,
when `WCAG_MODE=editors` is also set.
**Default:** `w3c/wcag`
## Other points of interest
- The main configuration can be found in top-level `eleventy.config.ts`
- Build commands are defined in top-level `package.json` under `scripts`,
and can be run via `npm run <name>`
- If you see files named `*.11tydata.*`, these contribute data to the Eleventy build
(see Template and Directory Data files under
[Sources of Data](https://www.11ty.dev/docs/data/#sources-of-data))
|
# JSON Serialization of WCAG 2
The script in this folder serializes WCAG 2 information into JSON format, including:
- Principles, guidelines, and success criteria
- Glossary terms
- Associations between (normative) success criteria and (informative) techniques
The following JSON files are published monthly:
- [WCAG 2.2 JSON](https://www.w3.org/WAI/WCAG22/wcag.json)
- [WCAG 2.1 JSON](https://www.w3.org/WAI/WCAG21/wcag.json)
For a history of structural changes to the JSON files, see the [list of merged wcag.json pull requests](https://github.com/w3c/wcag/pulls?q=is%3Apr+label%3Awcag.json), and in particular the "wcag.json Changes" section in each pull request description.
## Permission to use with attribution
You may use this data, in full or in part, provided you:
- Clearly attribute the original source and include a link to it ([Web Content Accessibility Guidelines (WCAG) 2.2](https://www.w3.org/TR/WCAG22/), [Techniques for WCAG 2.2](https://www.w3.org/WAI/WCAG22/Techniques/), [Web Content Accessibility Guidelines (WCAG) 2.1](https://www.w3.org/TR/WCAG21/), [Techniques for WCAG 2.1](https://www.w3.org/WAI/WCAG21/Techniques/))
- Do not change the content
If you include additional information, it must be clear what is from the W3C WCAG documents and what is added.
See [W3C Document license](https://www.w3.org/copyright/document-license/) and [W3C Intellectual rights](https://www.w3.org/copyright/intellectual-rights/), particularly '[May I annotate one of your specifications?](https://www.w3.org/copyright/intellectual-rights/#annotate)'.
|
---
title: Accessibility guides
short-title: Guides
slug: Web/Accessibility/Guides
page-type: listing-page
sidebar: accessibilitysidebar
---
This page lists guides for web accessibility.
They're intended to help you understand what kinds of things are possible to improve the accessibility of your projects on the web.
{{SubPagesWithSummaries}}
|
---
title: Accessibility and spatial patterns
short-title: Spatial patterns
slug: Web/Accessibility/Guides/Accessibility_and_Spatial_Patterns
page-type: guide
sidebar: accessibilitysidebar
---
This document describes visual patterns that can induce physical symptoms in people who have photosensitive epilepsy, vestibular disorders, or other perceptual issues.
## Spatial Localization
NASA conducted research on the perception of color, and found that luminance contrast mattered greatly as to how colors are perceived. The two images below are from NASA research, specifically, from the article, "[Designing With Blue](https://web.archive.org/web/20250216024807/https://colorusage.arc.nasa.gov/blue_2.php)"
 
> **Spatial Localization.** Symbols which have the same luminance as their background are perceptually less securely located in space and time than are symbols with higher luminance contrast. They tend to "float" visually or be "captured" by adjacent symbols with high luminance-contrast. The phenomenon seems to be especially problematic for symbol/background combinations that differ only in the blue channel.
## Distance between stripes
Photosensitive seizures may be caused by static images as well as animation. The mechanism for this is poorly understood, but is believed to be linked to "gamma oscillations" set up in the brain. These oscillations in the brain are a different kind of response than other kinds of neurological responses believed to cause photosensitive seizures.
Stripes and patterns are typical of the kinds of images that create problems, and stripes have been studied most closely. There's the potential for causing harm if there are more than five light-dark pairs of stripes in any orientation. They can be parallel, radial, curved or straight, and may be formed by rows of repeating elements.
In 2005, Arnold Wilkins, John Emmett, and Graham Harding evaluated the guidelines for characterizing patterned images that could precipitate seizures. They revised the guidelines to their fundamental core, and came up with a surprisingly simple, but powerful [test](https://onlinelibrary.wiley.com/doi/full/10.1111/j.1528-1167.2005.01405.x), which they published in the paper, **[Characterizing the Patterned Images That Precipitate Seizures and Optimizing Guidelines To Prevent Them](https://onlinelibrary.wiley.com/doi/full/10.1111/j.1528-1167.2005.01405.x)**
> [!NOTE]
> The steps necessary to evaluate material reduce to the following:
>
> Look at the screen:
>
> - Are there more than five stripes?
> - If so, do they last longer than 0.5 s?
> - If so, does the brightness exceed the stated limit?
> - If so, categorize the motion of the pattern.
> - Are the guidelines contravened?
>
> If so, reduce brightness.
## Text and padding
WCAG standards for contrast perception do not take into account the effect of padding. For example, blue text on a gray background is easier to perceive if it is surrounded "locally" by black than by white. There is such a thing as "local" adaptation to colors. The bottom line: padding matters.
## Math
Spatial reasoning affects Math learning; consequently, spatial relationships in how math is presented affects cognition. The web developer can do something about this in the manner in which they display math. Animation figures strongly in this arena. For example, "how" an object looks when it is rotated, from different angles, how they look sliced, and how they relate to each other in space all make a difference in an ability to understand Math in spatial terms.
## Braille
Modern technology enables non-experts to print Braille. Adobe Illustrator, for example, allows one to Typeset ADA Braille for printing out.
The ability to represent spatial patterns accurate to those who are blind is critical for accessibility. For example, knowing Braille is not enough. The Braille dots have to be spatially apart from one another so as to be readable in a "human" way. The human touch does distinguish with ease braille dots that are too close or too far apart from one another.
Space has to surround the braille character. A user of braille does not lay a finger on "top" of a braille character, the user has to move her finger over the character, in the way that a sighted person must move her eyes across text written on a page.
The nature of space can change depending upon what MIME type is being used, and its version. For example, borders on SVG can extend both inward and outward from its dimensions, or for newer versions of SVG, entirely outward from it, thus reducing the space around the SVG to enable perception.
## See also
### MDN
- [Accessibility: What users can do to browse more safely](/en-US/docs/Web/Accessibility/Guides/Browsing_safely)
- [Web accessibility for seizures and physical reactions](/en-US/docs/Web/Accessibility/Guides/Seizure_disorders)
- [Web Accessibility: Understanding Colors and Luminance](/en-US/docs/Web/Accessibility/Guides/Colors_and_Luminance)
### Braille
- [Part 3: A Step-by-Step Guide to Typesetting ADA Braille Correctly in Adobe Illustrator](https://www.tinkeringmonkey.com/guides/ada-signage/a-step-by-step-guide-to-typesetting-ada-braille-correctly-in-adobe-illustrator/)
- [Spatial Math in BrailleBlaster (4 of 5)](https://www.youtube.com/watch?v=yz9vefDsj1g)
### Math
- [Spatial Reasoning: Why Math Talk is About More Than Numbers](https://dreme.stanford.edu/news/spatial-reasoning-why-math-talk-is-about-more-than-numbers/)
### Scientific Literature
- [Color constancy in context: Roles for local adaptation and levels of reference](https://jov.arvojournals.org/article.aspx?articleid=2192799)
- [Gamma oscillations and photosensitive epilepsy](https://www.sciencedirect.com/science/article/pii/S0960982217304062?via%3Dihub)
- [Characterizing the Patterned Images That Precipitate Seizures and Optimizing Guidelines To Prevent Them](https://onlinelibrary.wiley.com/doi/epdf/10.1111/j.1528-1167.2005.01405.x) Arnold Wilkins, John Emmett, and Graham Harding
|
---
title: Mobile accessibility checklist
slug: Web/Accessibility/Guides/Mobile_accessibility_checklist
page-type: guide
sidebar: accessibilitysidebar
---
This document provides a concise checklist of accessibility requirements for mobile app developers. It is intended to continuously evolve as more patterns arise.
## Color
- Color contrast must comply with [WCAG 2.2 AA level requirements](https://w3c.github.io/wcag/guidelines/22/#contrast-minimum):
- Contrast ratio of 4.5:1 for normal text (less than 18 point or 14 point bold.)
- Contrast ratio of 3:1 for large text (at least 18 point or 14 point bold.)
- Information conveyed via color must be also available by other means too (underlined text for links, etc.)
## Visibility
- Content hiding techniques such as zero opacity, z-index order and off-screen placement must not be used exclusively to handle visibility.
- Everything other than the currently visible screen must be _truly_ invisible (especially relevant for single page apps with multiple _cards_):
- Use the `hidden` attribute or `visibility` or `display` style properties.
- Unless absolutely unavoidable, `aria-hidden` attribute should not be used.
## Focus
- All activatable elements must be focusable:
- Standard controls such as links, buttons, and form fields are focusable by default.
- Non-standard controls must have an appropriate [ARIA Role](/en-US/docs/Web/Accessibility/ARIA/Reference/Roles) assigned to them, such as `button`, `link`, or `checkbox`.
- Focus should be handled in a logical order and consistent manner.
## Text equivalents
- Text equivalent must be provided for every non-strictly presentational non-text element within the app.
- Use _alt_ and _title_ where appropriate (read Steve Faulkner's post about [Using the HTML title attribute](https://www.tpgi.com/using-the-html-title-attribute-updated/) for a good guide.)
- If the above attributes are not applicable, use appropriate [ARIA States and Properties](/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes) such as `aria-label`, `aria-labelledby`, or `aria-describedby`.
- Images of text must be avoided.
- All user interface components with visible text (or image of text) as labels must have the same text available in the programmatic [name](https://w3c.github.io/wcag/guidelines/22/#dfn-name) of the component. [WCAG 2.1: Label in name.](https://www.w3.org/WAI/WCAG21/Understanding/label-in-name.html)
- All form controls must have labels ({{ htmlelement("label") }} elements) for the benefit of screen reader users.
## Handling state
- Standard controls such as radio buttons and checkboxes are handled by the operating system. However, for other custom controls state changes must be provided via [ARIA States](https://w3c.github.io/aria/#state_prop_def) such as `aria-checked`, `aria-disabled`, `aria-selected`, `aria-expanded`, and `aria-pressed`.
## Orientation
- Content should not be restricted to a single orientation, such as portrait or landscape, unless essential. [WCAG 2.1: Orientation](https://www.w3.org/WAI/WCAG21/Understanding/orientation.html)
- Examples of when an orientation is essential is a piano application or a bank check.
## General guidelines
- An app title must be provided.
- Headings must not break hierarchical structure
```html
<h1>Top level heading</h1>
<h2>Secondary heading</h2>
<h2>Another secondary heading</h2>
<h3>Low level heading</h3>
```
- [ARIA Landmark Roles](/en-US/docs/Web/Accessibility/ARIA/Reference/Roles#3._landmark_roles) should be used to describe an app or document structure, such as `banner`, `complementary`, `contentinfo`, `main`, `navigation`, `search`.
- For touch events, ensure the following ([WCAG 2.1: Pointer Cancellation](https://www.w3.org/WAI/WCAG21/Understanding/pointer-cancellation.html)):
- The down-event should not be used to execute any part of the function;
- Failing the above, _completion_ of the function should be on the up-event, and a mechanism is available to abort the action before its completion or to undo the action after its completion;
- Failing the above, the up-event should be able to undo any action that was triggered on a down event;
- All the above may be violated if it is essential to trigger the action on the down event, usually to simulate real-world experiences or to provide real-time feedback. For example, game controls, piano keyboards, or virtual keyboards.
- Touch targets must be large enough for the user to interact with (see the [BBC Mobile Accessibility Guidelines](https://www.bbc.co.uk/accessibility/forproducts/guides/mobile/target-touch-size) for useful touch target size guidelines).
> [!NOTE]
> The [original version of this document](https://yzen.github.io/firefoxos/2014/04/30/mobile-accessibility-checklist.html) was written by [Yura Zenevich](https://yzen.github.io/).
|
---
title: "Accessibility: What personalization helps browse more safely"
short-title: Personalization to help browse safely
slug: Web/Accessibility/Guides/Browsing_safely
page-type: guide
sidebar: accessibilitysidebar
---
This article discusses making web content accessible for those with vestibular disorders, and those who support them, by taking advantage of personalization and accessibility settings built into the operating systems. Taking advantage of personalization settings can help prevent exposure to content leading to seizures and / or other physical reactions.
## Personalization and accessibility settings
From the article, "**[Understanding Success Criterion 2.3.1: Three Flashes or Below Threshold](https://www.w3.org/WAI/WCAG21/Understanding/three-flashes-or-below-threshold.html)**"
> Flashing can be caused by the display, the computer rendering the image or by the content being rendered. The author has no control of the first two. They can be addressed by the design and speed of the display and computer
### Hardware and operating systems on many computers offer control that is not afforded to developers
The user can do much to protect himself by learning his operating system, its personalization and accessibility settings. Those in the public sector who must accommodate those with special sensitivities, should consider setting aside at least one work station and becoming familiar with its personalization and accessibility settings. Understanding personalization and accessibility settings can actually be a money-saving endeavor. One work station can be set up to accommodate both a low-vision individual (needs high-contrast) and to accommodate an individual with photosensitive susceptibilities, by, adjusting personalization and accessibility settings.
### Use modern browsers. Learn personalization and accessibility settings
Modern browsers support the CSS media feature [`prefers-reduced-motion`](/en-US/docs/Web/CSS/Reference/At-rules/@media/prefers-reduced-motion). Browsers can detect whether a user has requested a reduced motion experience. The user would access this through an accessibility interface, as seen below.

CSS Transition events are supported. Examples include:
- `transitionrun`
- `transitionstart`
- `transitionend`
- `transitioncancel`
### Safari 10.1 and above (Desktop)
Do not enable Auto-Play (does not work for GIFs)
#### iOS Safari 10.3 and above (Mobile and Tablet)
Select the "Reduce motion option" in OS Accessibility settings for Apple (image source: developers.google.com from Thomas Steiner's article "Move Ya! Or maybe, don't, if the user prefers-reduced-motion!"). This will not work on animated GIFs; the source of the animation is self-contained within a gif and is not affected by these settings.
#### Use Reader Mode on browsers
- Enable Content Blockers; Gets rid of ads, reduces and/or removes distractions
- Enables text-to-speech
- In certain browsers, enable fonts by choice
- Enable Page Zoom
#### Turn off animated GIFs in the browser
Browsers offer much power to their users; it's just a matter of knowing where to go. Using Firefox as an example, it explains that by changing the value the **image.animation_mode** from "normal" to "none", all animated images will be blocked. To reverse it, you will have to change the value back to "normal"

#### Use browser extensions
- [Gif Blocker](https://chromewebstore.google.com/detail/gif-blocker/ahkidgegbmbnggcnmejhobepkaphkfhl?hl=en) For Chrome, GIF Blocker is an extension available at the web store.
- [Gif Scrubber](https://chromewebstore.google.com/detail/gif-scrubber/gbdacbnhlfdlllckelpdkgeklfjfgcmp?hl=en) Gif Scrubber is a chrome extension that allows you to control GIFs like a video player. There is a GitHub repository for it at **<https://github.com/0ui/gif-scrubber>**
- [Beeline Reader](https://www.beelinereader.com/) Beeline Reader has a browser extension that allows you to set up for grayscale and Dyslexi font, among other things

### Take advantage Operating System accessibility features
Most operating systems such as Windows 10, have accessibility options that are surprisingly powerful. Usually they are quite easy to find by typing (or saying) in the word, "Accessibility" in the search finder of the operating system.
#### Turn off animations in the operating system
In the Windows 10 operating system, the user has an ability to turn off animations. This will not work on animated GIFs; the source of the animation is self-contained within a gif and is not affected by these settings.

#### Grayscale
Those who have suffered traumatic brain injury (TBI) may be highly sensitive to color; it can require such a great "investment of cognitive energy" on their part, there's no energy for other daily tasks. Enabling grayscale presentation of the content reduces the cognitive workload. It may assist users with other disabilities, as well. An interesting discussion by users on the benefits of using grayscale may be found in the discussion thread, "[What is the "grayscale" setting for in accessibility options?](https://ask.metafilter.com/312049/What-is-the-grayscale-setting-for-in-accessibility-options)". Of particular interest is a user who has Photosensitive Epilepsy, and uses it when feeling "seizure-y".
Most Operating Systems have a way to let the user make an adjustment on the workstation. In the screenshot below, you can see an example of Windows 10 Accessibility Settings allowing for color filters to be selected. Grayscale is enabled when the color filters button is toggled "on"

## See also
- [Accessibility](/en-US/docs/Web/Accessibility)
- [Accessibility learning path](/en-US/docs/Learn_web_development/Core/Accessibility)
- [Web accessibility for seizures and physical reactions](/en-US/docs/Web/Accessibility/Guides/Seizure_disorders)
- [Color vision simulation](https://firefox-source-docs.mozilla.org/devtools-user/accessibility_inspector/simulation/index.html)
- Discussion: "[What is the "grayscale" setting for in accessibility options?](https://ask.metafilter.com/312049/What-is-the-grayscale-setting-for-in-accessibility-options)"
### Contributors
Many, many thanks to Eric Eggert from [Knowbility;](https://knowbility.org/) for his discussions and huge help on this topic.
|
---
title: Understanding the Web Content Accessibility Guidelines (WCAG)
short-title: Understanding WCAG
slug: Web/Accessibility/Guides/Understanding_WCAG
page-type: guide
sidebar: accessibilitysidebar
---
This set of articles provides quick explanations to help you understand the steps that need to be taken to conform to the recommendations outlined in the {{glossary("WCAG", "Web Content Accessibility Guidelines")}} (WCAG).
The WCAG guidelines are a set of recommendations for making web content more accessible developed by W3C's {{Glossary("WAI")}}, primarily for people with disabilities — but also for all user agents, including some highly limited devices or services, such as digital assistants.
WCAG 2.2 is the most recent version of the guidelines with WCAG 2.1 and 2.0 also widely used. WCAG 3.0 is the working draft.
Newer versions of WCAG are not meant to supersede previous versions, but WAI recommends using the most recent version to ensure the best possible accessibility for your website.
## The four principles
WCAG is broadly broken down into four principles — major things that web content **must be** to be considered accessible (see [Understanding the Four Principles of Accessibility](https://www.w3.org/WAI/WCAG22/Understanding/intro#understanding-the-four-principles-of-accessibility) for the WCAG definitions).
Each of the links below will take you to pages that further expand on these areas, giving you practical advice on how to write your web content so it conforms to the success criteria outlined in the WCAG 2 four guiding principles.
- [Perceivable](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Perceivable): Users must be able to perceive it in some way, using one or more of their senses.
- [Operable](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Operable): Users must be able to control UI elements (e.g., buttons must be clickable in some way — mouse, keyboard, voice command, etc.).
- [Understandable](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Understandable): The content must be understandable to its users.
- [Robust](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Robust): The content must be developed using well-adopted web standards that will work across different browsers, now and in the future.
We also included two additional WCAG resources focused on making sites [keyboard accessible](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Keyboard) and provided descriptive names or labels with [text labels and names](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Text_labels_and_names).
## Legal standing
This introductory documentation is intended to provide practical information to help you build better, more accessible websites. However, we are not lawyers, and none of this constitutes legal advice. If you are worried about the legal implications of web accessibility, we recommend that you check the specific legislation governing accessibility for the web and public resources in your country or locale and seek the advice of a qualified lawyer.
[What is accessibility?](/en-US/docs/Learn_web_development/Core/Accessibility/What_is_accessibility) and particularity the [Accessibility guidelines and the law](/en-US/docs/Learn_web_development/Core/Accessibility/What_is_accessibility#accessibility_guidelines_and_the_law) section provide more related information.
## See also
- [WCAG: Perceivable](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Perceivable) principle
- [WCAG: Operable](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Operable) principle
- [WCAG: Understandable](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Understandable) principle
- [WCAG: Robust](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Robust) principle
- [WCAG text labels and names](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Text_labels_and_names)
- [WCAG keyboard accessibility](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Keyboard)
- [WCAG Overview](https://www.w3.org/WAI/standards-guidelines/wcag/)
- [WCAG 2.2](https://w3c.github.io/wcag/guidelines/22/)
|
---
title: Keyboard accessible
slug: Web/Accessibility/Guides/Understanding_WCAG/Keyboard
page-type: guide
sidebar: accessibilitysidebar
---
To be fully accessible, a web page must be operable by someone using only a keyboard to access and control it. This includes users of screen readers, but can also include users who have trouble operating a pointing device such as a mouse or trackball, or whose mouse is not working at the moment, or who prefer to use a keyboard for input whenever possible.
## Focusable elements should have interactive semantics
If an element can be focused using the keyboard, then it should be interactive; that is, the user should be able to do something to it and produce a change of some kind (for example, activating a link or changing an option).
> [!NOTE]
> One important exception to this rule is if the element has `role="document"` applied to it, **inside** an interactive context (such as `role="application"`). In such a case, focusing the nested document is the only way of returning assistive technology to a non-interactive state (often called "browse mode").
Most interactive elements are focusable by default; you can make an element focusable by adding a `tabindex=0` attribute value to it. However, you should only add `tabindex` if you have also made the element interactive, for example, by defining appropriate event handlers keyboard events.
### See also
- [tabindex](/en-US/docs/Web/HTML/Reference/Global_attributes/tabindex) global HTML attribute
- Element: [keydown event](/en-US/docs/Web/API/Element/keydown_event)
- Element: [keyup event](/en-US/docs/Web/API/Element/keyup_event)
## Avoid using `tabindex` attribute greater than zero
The `tabindex` attribute indicates that an element is focusable using the keyboard. A value of zero indicates that the element is part of the default focus order, which is based on the ordering of elements in the HTML document. A positive value puts the element ahead of those in the default ordering; elements with positive values are focused in the order of their `tabindex` values (1, then 2, then 3, etc.).
This creates confusion for keyboard-only users when the focus order differs from the logical order of the page. A better strategy is to structure the HTML document so that focusable elements are in a logical order, without the need to re-order them with positive `tabindex` values.
### See also
- [tabindex](/en-US/docs/Web/HTML/Reference/Global_attributes/tabindex) global HTML attribute
- [Understanding focus order](https://www.w3.org/WAI/WCAG21/Understanding/focus-order.html)
- [Don't use tabindex greater than 0](https://adrianroselli.com/2014/11/dont-use-tabindex-greater-than-0.html)
## Clickable elements must be focusable and should have interactive semantics
If an element can be clicked with a pointing device, such as a mouse, then it should also be focusable using the keyboard, and the user should be able to do something by interacting with it.
An element is clickable if it has an `onclick` event handler defined. You can make it focusable by adding a `tabindex=0` attribute value to it. You can make it operable with the keyboard by defining an `onkeydown` event handler; in most cases, the action taken by event handler should be the same for both types of events.
### See also
- [tabindex](/en-US/docs/Web/HTML/Reference/Global_attributes/tabindex) global HTML attribute
- Element: [keydown event](/en-US/docs/Web/API/Element/keydown_event)
- Element: [keyup event](/en-US/docs/Web/API/Element/keyup_event)
## Interactive elements must be able to be activated using a keyboard
If the user can interact with an element using touch or a pointing device, then the element should also support interacting using the keyboard. That is, if you have defined event handlers for touch or click events, you should also define them for keyboard events. The keyboard event handlers should enable effectively the same interaction as the touch or click handlers.
### See also
- Element: [keydown event](/en-US/docs/Web/API/Element/keydown_event)
- Element: [keyup event](/en-US/docs/Web/API/Element/keyup_event)
## Interactive elements must be focusable
If the user can interact with an element (for example, using touch or a pointing device), then it should be focusable using the keyboard. You can make it focusable by adding a `tabindex=0` attribute value to it. That will add the element to the list of elements that can be focused by pressing the <kbd>Tab</kbd> key, in the sequence of such elements as defined in the HTML document.
### See also
- [tabindex](/en-US/docs/Web/HTML/Reference/Global_attributes/tabindex) global HTML attribute
## Focusable element must have focus styling
Any element that can receive keyboard focus should have visible styling that indicates when the element is focused. You can do this with the {{cssxref(":focus")}} and {{cssxref(":focus-visible")}} CSS pseudo-classes.
Standard focusable elements such as links and input fields are given special styling by the browser by default, so you might not need to specify focus styling for such elements, unless you want the focus styling to be more distinctive.
If you create your own focusable components, be sure that you also define focus styling for them.
### See also
- [Using CSS to change the presentation of a UI component when it receives focus](https://www.w3.org/WAI/WCAG21/Techniques/css/C15.html)
|
---
title: Robust
slug: Web/Accessibility/Guides/Understanding_WCAG/Robust
page-type: guide
sidebar: accessibilitysidebar
---
This article provides practical advice on how to write your web content so that it conforms to the success criteria outlined in the **Robust** principle of the Web Content Accessibility Guidelines (WCAG) 2.0 and 2.1. Robust states that content must be robust enough that it can be interpreted reliably by a wide variety of user agents, including assistive technologies. This can generally be achieved by following web standards and [testing rigorously](/en-US/docs/Learn_web_development/Extensions/Testing).
> [!NOTE]
> To read the W3C definitions for Robust and its guidelines and success criteria, see [Principle 4: Robust — Content must be robust enough that it can be interpreted reliably by a wide variety of user agents, including assistive technologies.](https://w3c.github.io/wcag/guidelines/22/#robust)
## Guideline 4.1 — Compatible: Maximize compatibility with current and future user agents, including assistive technologies
This guideline focuses on making content as compatible as possible, not only with current user agents (e.g., browsers), but also with future ones too.
<table class="standard-table">
<thead>
<tr>
<th scope="col">Success criteria</th>
<th scope="col">How to conform to the criteria</th>
<th scope="col">Practical resource</th>
</tr>
</thead>
<tbody>
<tr>
<td>4.1.1 Parsing (A)</td>
<td>
<p>
Content should be well-formed so it can be parsed successfully by
browsers and other user agents such as screen readers.
</p>
<p>
To pass this criterion, make sure that your HTML is as valid as
possible. Use the
<a href="https://validator.w3.org/">W3C validator</a> to validate your
markup.
</p>
</td>
<td>
See
<a href="/en-US/docs/Learn_web_development/Core/Structuring_content/Debugging_HTML"
>Debugging HTML</a
>
for a practical guide.
</td>
</tr>
<tr>
<td>4.1.2 Name, Role, Value (A)</td>
<td>
<p>
The name and role of user interface components (e.g., form inputs,
buttons, links, etc.) should be programmatically determinable.
</p>
<p>
When using semantic elements correctly for their intended purpose,
this criterion should be passed automatically. When scripting custom
components, you will need to use WAI-ARIA roles and other features to
make sure your controls will be interpreted and are able to be used as
intended, e.g., not only by sighted mouse users, but also by
screen reader users, keyboard-only users, etc.
</p>
</td>
<td>
See
<a href="/en-US/docs/Learn_web_development/Core/Accessibility/HTML"
>HTML: A good basis for accessibility</a
>
and
<a href="/en-US/docs/Learn_web_development/Core/Accessibility/WAI-ARIA_basics"
>WAI-ARIA basics</a
>.
</td>
</tr>
<tr>
<td>
4.1.3 Status Messages (AA)
</td>
<td>
<p>
Assistive technology users are made aware of new status messages added
to the page.
</p>
</td>
<td>
<a
href="https://www.w3.org/WAI/WCAG21/Understanding/status-messages.html"
>Understanding Status Messages</a
>
</td>
</tr>
</tbody>
</table>
> [!NOTE]
> Also see the WCAG description for [Guideline 4.1: Compatible: Maximize compatibility with current and future user agents, including assistive technologies.](https://w3c.github.io/wcag/guidelines/22/#compatible)
## See also
- [WCAG](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG)
1. [Perceivable](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Perceivable)
2. [Operable](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Operable)
3. [Understandable](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Understandable)
4. Robust
|
---
title: Perceivable
slug: Web/Accessibility/Guides/Understanding_WCAG/Perceivable
page-type: guide
sidebar: accessibilitysidebar
---
This article provides practical advice on how to write your web content so that it conforms to the success criteria outlined in the **Perceivable** principle of the Web Content Accessibility Guidelines (WCAG) 2.0 and 2.1. Perceivable states that users must be able to perceive it in some way, using one or more of their senses.
> [!NOTE]
> To read the W3C definitions for Perceivable and its guidelines and success criteria, see [Principle 1: Perceivable - Information and user interface components must be presentable to users in ways they can perceive.](https://w3c.github.io/wcag/guidelines/22/#perceivable)
## Guideline 1.1 — Providing text alternatives for non-text content
The key here is that text can be converted to other forms that people with disabilities can use. For example, it can be spoken by a screen reader, converted to large print, or represented on a braille display. Non-text content refers to multimedia such as images, audio, and video.
<table class="standard-table">
<thead>
<tr>
<th scope="col">Success criteria</th>
<th scope="col">How to conform to the criteria</th>
<th scope="col">Practical resource</th>
</tr>
</thead>
<tbody>
<tr>
<td rowspan="5">1.1.1 Provide text equivalents (A)</td>
<td>
All images that convey meaningful content should be given suitable
alternative text.
</td>
<td>
<a href="/en-US/docs/Learn_web_development/Core/Accessibility/HTML#text_alternatives"
>Text alternatives.</a
>
</td>
</tr>
<tr>
<td>
Complex images or charts should have an accessible alternative provided,
either on the same page or via a link. Use a regular link instead of
a <code>longdesc</code> attribute.
</td>
<td>
<p>
A text description may work, or an accessible data table (see
<a href="/en-US/docs/Learn_web_development/Core/Structuring_content/Table_accessibility"
>HTML table accessibility</a
>). See W3C's
<a href="https://www.w3.org/TR/html-longdesc/">Image Description Extension (longdesc)</a>
for the argument against <code>longdesc</code>.
</p>
</td>
</tr>
<tr>
<td>
Multimedia content (i.e., audio or video) should at least have a
descriptive identification available, such as a caption or similar.
</td>
<td>
<p>
See <a href="/en-US/docs/Learn_web_development/Core/Accessibility/HTML#text_alternatives"
>Text alternatives</a
>
for static caption options, and
<a href="/en-US/docs/Learn_web_development/Core/Accessibility/Multimedia#audio_transcripts"
>Audio transcripts</a
>,
<a href="/en-US/docs/Learn_web_development/Core/Accessibility/Multimedia#video_text_tracks"
>Video text tracks</a
>
for other alternatives.
</p>
</td>
</tr>
<tr>
<td>
UI controls such as form elements and buttons should have text labels
that describe their purpose.
</td>
<td>
Buttons are simple—you should make sure the button text describes the
function of the button (e.g., <code
><button>Upload image</button></code
>). For more information on other UI controls, see
<a href="/en-US/docs/Learn_web_development/Core/Accessibility/HTML#use_semantic_ui_controls_where_possible"
>Use semantic UI controls where possible</a
>.
</td>
</tr>
<tr>
<td>
Implement decorative (non-content) images, video, etc., in a way that is
invisible to assistive technology, so it doesn't confuse users.
</td>
<td>
<p>
Decorative images should be implemented using CSS background images
(see
<a
href="/en-US/docs/Learn_web_development/Core/Styling_basics/Backgrounds_and_borders"
>Backgrounds and borders</a
>). If you have to include an image via an
{{htmlelement("img")}} element, give it a blank alt
(<code>alt=""</code>). Otherwise, screen readers may try to read out
the filepath, etc.
</p>
<p>
If you are including background video or audio that autoplays, make it
as unobtrusive as possible. Don't make it look/sound like content, and
provide a control to turn it off. Ideally, don't include it at all.
</p>
</td>
</tr>
</tbody>
</table>
> [!NOTE]
> Also see the [WCAG description for Guideline 1.1: Text alternatives](https://w3c.github.io/wcag/guidelines/22/#text-alternatives).
## Guideline 1.2 — Providing text alternatives for time-based media
Time-based media refers to multimedia with a duration, such as audio and video. Note that if the audio/video serves as an alternative to existing text content, you don't need to provide another text alternative.
<table>
<thead>
<tr>
<th scope="col">Success criteria</th>
<th scope="col">How to conform to the criteria</th>
<th scope="col">Practical resource</th>
</tr>
</thead>
<tbody>
<tr>
<td>1.2.1 Provide alternatives for pre-recorded audio-only and video-only content (A)</td>
<td>A transcript should be provided for prerecorded audio-only media, and a transcript or audio description should be provided for prerecorded video-only media (i.e., silent video).</td>
<td>See <a href="/en-US/docs/Learn_web_development/Core/Accessibility/Multimedia#audio_transcripts">Audio transcripts</a> for transcript information. No audio description tutorial is available yet.</td>
</tr>
<tr>
<td>1.2.2 Provide captions for web-based video (A)</td>
<td>You should provide captions for video presented on the web (e.g., HTML video). This is for the benefit of people who can't hear the audio part of the video.</td>
<td>See <a href="/en-US/docs/Learn_web_development/Core/Accessibility/Multimedia#video_text_tracks">Video text tracks</a> for HTML video captions. See also <a href="https://support.google.com/youtube/answer/2734796?hl=en">Add your own subtitles & closed captions</a> (YouTube).</td>
</tr>
<tr>
<td>1.2.3 Provide text transcript or audio description for web-based video (A)</td>
<td>You should provide text transcripts or audio descriptions for video presented on the web (e.g., HTML video. This is for the benefit of people who can't see the visual part of the video, and don't get the full content from the audio alone.</td>
<td>See <a href="/en-US/docs/Learn_web_development/Core/Accessibility/Multimedia#audio_transcripts">Audio transcripts</a> for transcript information. No audio description tutorial is available yet.</td>
</tr>
<tr>
<td>1.2.4 Provide captions for live audio (AA)</td>
<td>You should provide synchronized captions for all live multimedia that contains audio (e.g., video conferences, live audio broadcasts).</td>
<td></td>
</tr>
<tr>
<td>1.2.5 Provide audio descriptions for prerecorded video (AA)</td>
<td>Audio descriptions should be provided for prerecorded video, but only where the existing audio does not convey the full meaning expressed by the video.</td>
<td></td>
</tr>
<tr>
<td>1.2.6 Provide sign language equivalent to prerecorded audio (AAA)</td>
<td>An equivalent sign language video should be provided for any prerecorded content containing audio.</td>
<td></td>
</tr>
<tr>
<td>1.2.7 Provide extended video with audio descriptions (AAA)</td>
<td>Where audio descriptions cannot be provided (see 1.2.5) due to video timing issues (e.g., there are no suitable pauses in the content in which to insert the audio descriptions), an alternative version of the video should be provided that includes inserted pauses (and audio descriptions).</td>
<td></td>
</tr>
<tr>
<td>1.2.8 Provide an alternative for prerecorded media (AAA)</td>
<td>For all content that features video, a descriptive text transcript should be provided, for example a script of the movie you are watching. This is for the benefit of hearing-impaired viewers who cannot hear the content.</td>
<td>See <a href="/en-US/docs/Learn_web_development/Core/Accessibility/Multimedia#audio_transcripts">Audio transcripts</a> for transcript information.</td>
</tr>
<tr>
<td>1.2.9 Provide a transcript for live audio (AAA)</td>
<td>For any live audio content being broadcast, a descriptive text should be provided, for example a script of the play or musical you are listening to. This is for the benefit of hearing-impaired viewers who cannot hear the content.</td>
<td>See <a href="/en-US/docs/Learn_web_development/Core/Accessibility/Multimedia#audio_transcripts">Audio transcripts</a> for transcript information.</td>
</tr>
</tbody>
</table>
> [!NOTE]
> Also see the [WCAG description for Guideline 1.2: Time-based Media: Provide alternatives for time-based media](https://w3c.github.io/wcag/guidelines/22/#time-based-media).
## Guideline 1.3 — Create content that can be presented in different ways
This guideline refers to the ability of content to be consumed by users in multiple ways, accommodating their differing needs.
<table class="standard-table">
<tbody>
<tr>
<th scope="col">Success criteria</th>
<th scope="col">How to conform to the criteria</th>
<th scope="col">Practical resource</th>
</tr>
<tr>
<td>1.3.1 Info and relationships (A)</td>
<td>
<p>
Any content structure—or visual relationship made between content—can
also be determined programmatically, or be inferred from text
description. The main situations in which this is relevant are:
</p>
<ul>
<li>
Text labels and the form elements they describe. These are
associated unambiguously using the {{htmlelement("label")}}
element, which can be picked up by screen readers, etc.
</li>
<li>
Image alt text. Content images should have text available that
clearly describes the image's contents, which can be
programmatically associated with it (e.g., alt text),
or otherwise is easy to associate (e.g., describes it and is sat
right next to it). This should mean that the full meaning can still
be inferred even if you can't see the image.
</li>
<li>
Lists. If the order of list items is important, use an ordered list
({{htmlelement("ol")}}).
</li>
</ul>
</td>
<td>
The whole of
<p>
<a href="/en-US/docs/Learn_web_development/Core/Accessibility/HTML"
>HTML: A good basis for accessibility</a
>
is packed with information about this, but you should particularly
refer to
<a href="/en-US/docs/Learn_web_development/Core/Accessibility/HTML#good_semantics"
>Good semantics</a
>,
<a href="/en-US/docs/Learn_web_development/Core/Accessibility/HTML#use_semantic_ui_controls_where_possible"
>Use semantic UI controls where possible</a
>, and
<a href="/en-US/docs/Learn_web_development/Core/Accessibility/HTML#text_alternatives"
>Text alternatives</a
>.
</p>
</td>
</tr>
<tr>
<td>1.3.2 Meaningful content sequence (A)</td>
<td>
A sensible, logical reading order should be easy to determine for any
content, even if it is visually presented in an unusual way. The order
should be made obvious by use of correct semantic elements (e.g.,
headings, paragraphs), with CSS being used to create any unusual layout
styles, irrespective of the markup.
</td>
<td>
Again, refer to
<a href="/en-US/docs/Learn_web_development/Core/Accessibility/HTML"
>HTML: A good basis for accessibility</a
>.
</td>
</tr>
<tr>
<td>1.3.3 Sensory characteristics (A)</td>
<td>
<p>
Instructions for operating controls or understanding content do not
rely on a single sense. This may prove inaccessible to people with a
disability related to that sense, or a device that does not support
that sense. So, for example:
</p>
<ul>
<li>
"Click the round button to continue"<br />The button should be
clearly labelled so that it is obvious that it is the button you
need to press. If there are multiple buttons, make sure they are all
clearly labelled to distinguish their function.
</li>
<li>
"Listen to the audio instructions for guidance"<br />This is
obviously problematic—audio will be inaccessible to those with
hearing impairments, whereas text can be read, but also spoken by a
screen reader if required.
</li>
<li>
"Swipe from the right-hand side of the screen to reveal the menu"<br />Some
users might not be able to swipe the screen, either due to
disability or because their device does not support touch. An
alternative should be provided, such as a keyboard shortcut or
button that can be activated by keyboard or other means.
</li>
</ul>
<div class="note notecard">
<p>
<strong>Note:</strong> Conveying instructions solely by color is
related, but covered in a different guideline — 1.4.1.
</p>
</div>
</td>
<td></td>
</tr>
<tr>
<td>
1.3.4 Orientation (AA)
</td>
<td>
Content does not restrict its view and operation to a single display
orientation, such as portrait or landscape, unless a specific display
orientation is essential.
</td>
<td>
<p>
<a href="https://www.w3.org/WAI/WCAG21/Understanding/orientation.html"
>Understanding Orientation</a
>
</p>
</td>
</tr>
<tr>
<td>
1.3.5 Identify Input Purpose (AA)
</td>
<td>
<p>
Follow the list of
<a href="https://w3c.github.io/wcag/guidelines/22/#input-purposes"
>53 input fields</a
>
to programmatically identify the purpose of a field.
</p>
</td>
<td>
<a
href="https://www.w3.org/WAI/WCAG21/Understanding/identify-input-purpose.html"
>Understanding Identify Input Purpose</a
>
</td>
</tr>
<tr>
<td>
1.3.6 Identify Purpose (AAA)
</td>
<td>
In content implemented using markup languages, the purpose of user
interface components, icons, and regions can be programmatically
determined.
</td>
<td>
<a
href="https://www.w3.org/WAI/WCAG21/Understanding/identify-purpose.html"
>Understanding Identify Purpose</a
>
</td>
</tr>
</tbody>
</table>
> [!NOTE]
> Also see the WCAG description for [Guideline 1.3: Adaptable: Create content that can be presented in different ways without losing information or structure.](https://w3c.github.io/wcag/guidelines/22/#adaptable)
## Guideline 1.4: Make it easier for users to see and hear content including separating foreground from background
This guideline relates to making sure core content is easy to discern from backgrounds and other decoration. The classic example is color (both [color contrast](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Perceivable/Color_contrast) and [use of color](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Perceivable/Use_of_color) to convey instructions), but it applies in other situations too.
<table class="standard-table">
<thead>
<tr>
<th scope="col">Success criteria</th>
<th scope="col">How to conform to the criteria</th>
<th scope="col">Practical resource</th>
</tr>
<tr>
<td>1.4.1 Use of color (A)</td>
<td>
<p>
Color should not be solely relied upon to convey information. For
example, in forms, you should never mark required fields purely with a
color (like red). Instead (or as well as), something like an asterisk
with a label of "required" would be more appropriate.
</p>
</td>
<td>
See
<a href="/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Perceivable/Use_of_color"
>Use of color</a
>,
<a
href="/en-US/docs/Learn_web_development/Core/Accessibility/CSS_and_JavaScript#color_and_color_contrast"
>Color and color contrast</a
>,
and
<a
href="/en-US/docs/Learn_web_development/Extensions/Forms/How_to_structure_a_web_form#multiple_labels"
>Multiple labels</a
>.
</td>
</tr>
<tr>
<td>1.4.2 Audio controls (A)</td>
<td>
For any audio that plays for longer than three seconds, provide
accessible controls to play and pause the audio/video, and mute/adjust
volume.
</td>
<td>
Use native <code><button></code>s to provide accessible keyboard
controls, as shown in
<a
href="/en-US/docs/Web/Media/Guides/Audio_and_video_delivery/Video_player_styling_basics"
>Video player styling basics</a
>.
</td>
</tr>
<tr>
<td>1.4.3 Minimum contrast (AA)</td>
<td>
<p>
The color contrast between background and foreground content should be
at a minimum level to ensure legibility:
</p>
<ul>
<li>
Text and its background should have a contrast ratio of at least
4.5:1.
</li>
<li>
Heading (or just larger) text should have a ratio of at least 3:1.
Larger text is defined as at least 18pt, or 14pt bold.
</li>
</ul>
</td>
<td>
See
<a href="/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Perceivable/Color_contrast"
>Color contrast</a
> and
<a
href="/en-US/docs/Learn_web_development/Core/Accessibility/CSS_and_JavaScript#color_and_color_contrast"
>Color and color contrast</a
>.
</td>
</tr>
<tr>
<td>1.4.4 Resize text (AA)</td>
<td>
The page should be readable and usable when the text size is doubled.
This means that designs should be responsive, so that when the text size
is increased, the content is still accessible.
</td>
<td></td>
</tr>
<tr>
<td>1.4.5 Images of text (AA)</td>
<td>
Images should NOT be used to present content where text would do the
job. For example, if an image is mostly textual, it could be represented
using text as well as images.
</td>
<td></td>
</tr>
<tr>
<td>1.4.6 Enhanced contrast (AAA)</td>
<td>
<p>This follows, and builds on, criterion 1.4.3.</p>
<ul>
<li>
Text and its background should have a contrast ratio of at least
7:1.
</li>
<li>
Heading (or just larger) text should have a ratio of at least 4.5:1.
Larger text is defined as at least 18pt, or 14pt bold.
</li>
</ul>
</td>
<td>
See
<a
href="/en-US/docs/Learn_web_development/Core/Accessibility/CSS_and_JavaScript#color_and_color_contrast"
>Color and color contrast</a
>.
</td>
</tr>
<tr>
<td>1.4.7 Low or no background audio (AAA)</td>
<td>
Prerecorded audio recordings that primarily feature speech should have
minimal background noise, so the content can be easily understood.
</td>
<td></td>
</tr>
<tr>
<td>1.4.8 Visual presentation (AAA)</td>
<td>
<p>For text content presentation, the following should be true:</p>
<ul>
<li>Foreground and background colors should be user-selectable.</li>
<li>
Text blocks should be no wider than 80 characters (or glyphs), for
maximum readability.
</li>
<li>
Text should not be fully justified (e.g., <code
>text-align: justify;</code
>).
</li>
<li>
Line height should be at least 1.5 times the text size within
paragraphs (e.g., <code>line-height: 1.5;</code>), and at least 2.25
times the text size between paragraphs (e.g., <code
>padding: 2.25rem;</code
>).
</li>
<li>
When the text size is doubled, the content should not need to be
scrolled.
</li>
</ul>
</td>
<td></td>
</tr>
<tr>
<td>1.4.9 Images of text (No Exception) (AAA)</td>
<td>
Text should not be presented as part of an image unless it is purely
decoration (i.e., it does not convey any content) or cannot be presented
in any other way.
</td>
<td></td>
</tr>
<tr>
<td>
1.4.10 Reflow (AA)
</td>
<td>
<ul>
<li>
No horizontal scrolling for left-to-right languages (like English)
or right-to-left languages (like Arabic)
</li>
<li>
No vertical scrolling for top-to-bottom languages (like Japanese)
</li>
<li>
Except for parts of the content which require two-dimensional layout
for usage or meaning (like a large data table)
</li>
</ul>
</td>
<td>
<a href="https://www.w3.org/WAI/WCAG21/Understanding/reflow.html"
>Understanding Reflow</a
>
</td>
</tr>
<tr>
<td>
1.4.11 Non-Text Contrast(AA)
</td>
<td>
Minimum color contrast ratio of 3:1 for user interface components and
graphical objects.
</td>
<td>
<a
href="https://www.w3.org/WAI/WCAG21/Understanding/non-text-contrast.html"
>Understanding Non-Text Contrast</a
>
</td>
</tr>
<tr>
<td>
1.4.12 Text Spacing (AA)
</td>
<td>
<p>
No loss of content or functionality occurs when the following styles
are applied:
</p>
<ul>
<li>
Line height (line spacing) to at least 1.5 times the font size
</li>
<li>
Spacing following paragraphs to at least 2 times the font size
</li>
<li>
Letter spacing (tracking) to at least 0.12 times the font size
</li>
<li>Word spacing to at least 0.16 times the font size</li>
</ul>
</td>
<td>
<a href="https://www.w3.org/WAI/WCAG21/Understanding/text-spacing.html"
>Understanding Text Spacing</a
>
</td>
</tr>
<tr>
<td>
1.4.13 Content on Hover or Focus (AA)
</td>
<td>
<p>
While additional content may appear and disappear in coordination with
hover and keyboard focus, this success criterion specifies three
conditions that must be met:
</p>
<ul>
<li>dismissible (can be closed/removed)</li>
<li>
hoverable (the additional content does not disappear when the
pointer is over it)
</li>
<li>
persistent (the additional content does not disappear without user
action)
</li>
</ul>
</td>
<td>
<a
href="https://www.w3.org/WAI/WCAG21/Understanding/content-on-hover-or-focus.html"
>Understanding Content on Hover or Focus</a
>
</td>
</tr>
</thead>
</table>
> [!NOTE]
> Also see the WCAG description for [Guideline 1.4: Distinguishable: Make it easier for users to see and hear content including separating foreground from background.](https://w3c.github.io/wcag/guidelines/22/#distinguishable)
## See also
- [WCAG](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG)
1. Perceivable
2. [Operable](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Operable)
3. [Understandable](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Understandable)
4. [Robust](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Robust)
|
---
title: Color contrast
slug: Web/Accessibility/Guides/Understanding_WCAG/Perceivable/Color_contrast
page-type: guide
sidebar: accessibilitysidebar
---
The [color contrast](https://w3c.github.io/wcag/guidelines/22/#dfn-contrast-ratio) between background and foreground content (that is, usually text) should be great enough to ensure legibility.
When designing readable interfaces for different vision capabilities, the WCAG guidelines recommend the following contrast ratios:
| Type of content | Minimum ratio (AA rating) | Enhanced ratio (AAA rating) |
| ------------------------------------------------------------------------------- | ------------------------- | --------------------------- |
| Body text | 4.5 : 1 | 7 : 1 |
| Large-scale text (120-150% larger than body text) | 3 : 1 | 4.5 : 1 |
| Active user interface components and graphical objects such as icons and graphs | 3 : 1 | Not defined |
These ratios do not apply to "incidental" text, such as inactive controls, logotypes, or purely decorative text.
See the [Solution](#solution) section below for further information.
Having good color contrast on your site benefits all your users, but it is particularly beneficial to users with certain types of color blindness and other similar conditions, who experience low contrast, and have trouble differentiating between similar colors. This is because they don't see bright and dark areas as readily as those without such conditions, and therefore have trouble seeing edges, borders, and other details.
It is good to have a cool design on your website, but the design is worthless if your users can't read your content.
## Examples
Let's have a look at some HTML and CSS code:
```html
<div class="good">Good contrast</div>
<div class="bad">Bad contrast</div>
```
```css
div {
/* General div styles here */
}
.good {
background-color: #5a80a9;
}
.bad {
background-color: #400064;
}
```
Both pieces of text have their default black color.
### Good Contrast
The "good" `<div>` has a neon blue background, which makes the text easy to read:
```html
<div class="good">Good contrast</div>
```
```css
div {
font-family: sans-serif;
text-align: center;
font-size: 2rem;
font-weight: bold;
width: 250px;
padding: 30px;
border-radius: 20px;
box-shadow: 4px 4px 4px black;
}
.good {
background-color: #5a80a9;
}
```
{{EmbedLiveSample('Good_Contrast', '100%', '100')}}
### Bad Contrast
The "bad" `<div>` on the other hand has a very dark purple background, which makes the text much harder to read:
```html
<div class="bad">Bad contrast</div>
```
```css
div {
font-family: sans-serif;
text-align: center;
font-size: 2rem;
font-weight: bold;
width: 250px;
padding: 30px;
border-radius: 20px;
box-shadow: 4px 4px 4px black;
}
.bad {
background-color: #400064;
}
```
{{EmbedLiveSample('Bad_Contrast', '100%', '100')}}
## Solution
When choosing a color scheme for your website, choose foreground and background colors that have good contrast. Make the color contrast as good as it can be within your design constraints — ideally go for the AAA rating (see 1.4.6 below), but at least meet the AA rating (see 1.4.3 below).
If you are including non-text content such as video or animation, you should follow 1.4.11 (again, see below).
To check your contrast as you make your color choices, use a tool such as WebAIM's [Color Contrast Checker](https://webaim.org/resources/contrastchecker/).
You can also check color contrast on the fly using Firefox's Developer Tools — see the [Accessibility inspector](https://firefox-source-docs.mozilla.org/devtools-user/accessibility_inspector/index.html) guide, and in particular the section [Check for accessibility issues](https://firefox-source-docs.mozilla.org/devtools-user/accessibility_inspector/index.html#check-for-accessibility-issues). Try using it on the live examples in the description section.
## Related WCAG success criteria
- [1.4.3 Minimum contrast (AA)](https://w3c.github.io/wcag/guidelines/22/#contrast-minimum)
- : The color contrast between background and foreground content should be at a minimum level to ensure legibility:
- Text and its background should have a contrast ratio of at least 4.5:1.
- Heading (or just larger) text should have a ratio of at least 3:1. Larger text is defined as at least 18pt, or 14pt bold.
- [1.4.6 Enhanced contrast (AAA)](https://w3c.github.io/wcag/guidelines/22/#contrast-enhanced)
- : This follows, and builds on, criterion 1.4.3.
- Text and its background should have a contrast ratio of at least 7:1.
- Heading (or just larger) text should have a ratio of at least 4.5:1.
- [1.4.11 Non-Text Contrast (AA)](https://w3c.github.io/wcag/guidelines/22/#non-text-contrast)
- : There should be a minimum color contrast ratio of 3 to 1 for user interface components and graphical objects.
## See also
- [Color and color contrast](/en-US/docs/Learn_web_development/Core/Accessibility/CSS_and_JavaScript#color_and_color_contrast)
- [Multiple labels](/en-US/docs/Learn_web_development/Extensions/Forms/How_to_structure_a_web_form#multiple_labels)
- [Understanding Non-Text Contrast](https://www.w3.org/WAI/WCAG21/Understanding/non-text-contrast.html)
|
---
title: Use of color
slug: Web/Accessibility/Guides/Understanding_WCAG/Perceivable/Use_of_color
page-type: guide
sidebar: accessibilitysidebar
---
While [color contrast](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Perceivable/Color_contrast) is often primarily an aesthetic choice, the _use of color_ on a website pertains to _using color to communicate information_. WCAG guideline 1.4.1 on the use of color requires that "color is not used as the only visual means of conveying information, indicating an action, prompting a response, or distinguishing a visual element."
## Solution
Use another factor in addition to color to convey information. For example, to indicate form validation errors, you can change the labels of the relevant fields by another font attribute as well as by color. Icons and symbols should differ by shape as well as by color.
To accommodate users with color vision disorders ("color blindness"), be careful when using a "stoplight" color metaphor, with green indicating "good" values and red indicating "bad" values. Users with red-green color blindness have trouble distinguishing red and green, and so may not be able to tell these values apart. Using an additional factor to signal "good" vs. "bad" is necessary. Avoid pure red and green in this situation; a reddish-orange and a bluish-green are distinguishable by color blind users, while still conveying the cultural "good" and "bad" meanings to users with normal color vision. [Color contrast](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Perceivable/Color_contrast) can be helpful in this context, as well, if one color is darker or lighter than the other.
## Related WCAG success criteria
- [1.4.1 Use of color (A)](https://w3c.github.io/wcag/guidelines/22/#use-of-color)
- : Color is not used as the only visual means of conveying information, indicating an action, prompting a response, or distinguishing a visual element.
## See also
- [Understanding Success Criterion 1.4.1: Use of Color](https://www.w3.org/WAI/WCAG21/Understanding/use-of-color.html)
- [Color contrast](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Perceivable/Color_contrast)
- [Color and color contrast](/en-US/docs/Learn_web_development/Core/Accessibility/CSS_and_JavaScript#color_and_color_contrast) in the Accessibility tutorials
|
---
title: Text labels and names
slug: Web/Accessibility/Guides/Understanding_WCAG/Text_labels_and_names
page-type: guide
sidebar: accessibilitysidebar
---
There are many situations in which a control, dialog, or other website feature should be given a descriptive name or label to allow users of assistive technologies to understand what its purpose is and how to operate it correctly. There are a number of different types of problems in this category, found in different contexts, and each has its own solution. The different problems and solutions are discussed in the sections below.
## Use alt attribute to label area elements that have the href attribute
In image maps, give each {{htmlelement("area")}} element an `alt` attribute containing a name that describes what resources the areas links to. Failure to do so makes an image map hard to use for users of assistive technology — they need alternative text to be able to understand the purpose of an image.
### Examples
The following example show an image map (taken from [H24: Providing text alternatives for the area elements of image maps](https://www.w3.org/TR/WCAG20-TECHS/H24.html)):
```html
<img
src="welcome.gif"
usemap="#map1"
alt="Areas in the library. Select an area for
more information on that area." />
<map id="map1" name="map1">
<area shape="rect" coords="0,0,30,30" href="reference.html" alt="Reference" />
<area
shape="rect"
coords="34,34,100,100"
href="media.html"
alt="Audio visual lab" />
</map>
```
See the [`<area>` element reference page](/en-US/docs/Web/HTML/Reference/Elements/area) for a live interactive example.
### See also
- {{htmlelement("area")}}
- [H24: Providing text alternatives for the area elements of image maps](https://www.w3.org/TR/WCAG20-TECHS/H24.html)
## Dialogs should be labeled
For any container whose contents act as a dialog box (for example, a modal dialog asking the user to make a choice or respond to an action being taken), give it a descriptive label or name, so that assistive technology users can easily discover what its purpose is.
A dialog box is generally denoted by an ARIA [`role="dialog"`](/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/dialog_role) or [`role="alertdialog"`](/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/alertdialog_role); you can use the [`aria-label`](/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-label) or [`aria-labelledby`](/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-labelledby) attributes to provide a label.
### Examples
The following example shows a dialog box, defined as such using `role="dialog"` and labelled using `aria-labelledby`.
```html
<div
role="dialog"
aria-labelledby="dialog1Title"
aria-describedby="dialog1Desc">
<h2 id="dialog1Title">Your personal details were successfully updated</h2>
<p id="dialog1Desc">
You can change your details at any time in the user account section.
</p>
<button>Close</button>
</div>
```
If the dialog box doesn't have a heading, you can instead use `aria-label` to contain the label text:
```html
<div role="dialog" aria-label="Personal details updated confirmation">
<p>
Your personal details were successfully updated. You can change your details
at any time in the user account section.
</p>
<button>Close</button>
</div>
```
### See also
- [`role="dialog"`](/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/dialog_role)
- [`role="alertdialog"`](/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/alertdialog_role)
- [`aria-label`](/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-label)
- [`aria-labelledby`](/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-labelledby)
- [Dialog authoring practices](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/)
## Documents must have a title
It is important in each HTML document to include a {{htmlelement("title")}} that describes the page's purpose. A common navigation technique for users of assistive technology is to infer what content a page contains by reading its title. If the title is not available, they have to navigate the page to determine its content, which can be a time consuming and potentially confusing process.
### Examples
The title for the reference article about the {{htmlelement("title")}} element is as follows:
```html
<title>
<title>: The Document Title element - HTML: Hypertext Markup Language |
MDN
</title>
```
Another example might look like so:
```html
<title>Fill in your details to register — myGov services</title>
```
To help the user, you can update the page title value to reflect significant page state changes (such as form validation problems):
```html
<title>2 errors — Fill in your details to register — myGov services</title>
```
### See also
- {{htmlelement("title")}}
## Embedded content must be labeled
Make sure that elements that embed content have a [title](/en-US/docs/Web/HTML/Reference/Global_attributes/title) attribute that describes the embedded content. This includes the {{htmlelement("embed")}} and {{htmlelement("object")}} elements. These elements are often used for graphical content, much like the {{HTMLelement("img")}} element. A descriptive title helps users of assistive technology understand what the element is showing.
## Figures with optional captions should be labeled
For best accessibility, include a {{HTMLElement("figcaption")}} within a {{HTMLElement("figure")}} element, even though doing so is technically optional. The caption is in addition to any alternative text on images within the figure. The caption describes the purpose of the figure in the document, which may be different from a description of a visual item, as provided by the alternative text.
### Example
The following example shows code for a figure with a caption. The `alt` attribute of the {{htmlelement("img")}} describes the appearance of the image; the {{htmlelement("figcaption")}} describes it from a functional perspective (in this case, the Latin name of the flower in the image).
```html
<figure>
<img
src="milkweed.jpg"
alt="Black and white close-up photo of milkweed flowers" />
<figcaption>Asclepias verticillata</figcaption>
</figure>
```
## Fieldset elements must be labeled
Fieldset elements must have a text description, similar to other form elements. Use the {{htmlelement("legend")}} element to describe the purpose of a fieldset.
## Use a legend to label a fieldset
When grouping a set of form elements together with a {{htmlelement("fieldset")}} element, you should include a nested {{htmlelement("legend")}} element inside it, containing a clear description of the group.
Users of assistive technology find this description helpful when trying to work out the overall purpose of the group. Without the legend, they would have to navigate around the individual form controls in the group to infer an idea of the overall purpose, which could result in confusion.
### Examples
```html
<form>
<fieldset>
<legend>Choose your favorite monster</legend>
<input type="radio" id="kraken" name="monster" value="K" />
<label for="kraken">Kraken</label><br />
<input type="radio" id="sasquatch" name="monster" value="S" />
<label for="sasquatch">Sasquatch</label><br />
<input type="radio" id="mothman" name="monster" value="M" />
<label for="mothman">Mothman</label>
</fieldset>
</form>
```
You can see a live, interactive version of this example on the [`<fieldset>` reference page](/en-US/docs/Web/HTML/Reference/Elements/fieldset).
### See also
- {{htmlelement("fieldset")}}
- {{htmlelement("legend")}}
## Form elements must be labeled
All elements within a form must have a {{htmlelement("label")}} that identifies its purpose. This applies to all types of {{htmlelement("input")}} items, as well as {{htmlelement("button")}}, {{htmlelement("output")}}, {{htmlelement("select")}}, {{htmlelement("textarea")}}, {{htmlelement("progress")}} and {{htmlelement("meter")}} elements, as well as any element with the [`switch` ARIA role](/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/switch_role).
The form element can be placed inside the {{htmlelement("label")}}, in which case the association between the form element and the label is obvious from the structure. Or, you can create an association between a {{htmlelement("label")}} and a form element by specifying the form element's `id` value as the value of the label's `for` attribute.
### Example
```html
<label
>I agree to the terms and conditions.
<input type="checkbox" id="terms" name="terms" />
</label>
<input type="checkbox" id="email-opt-in" name="opt-in" />
<label for="email-opt-in">Yes, please send me news about this product.</label>
```
## Form elements should have a visible text label
In addition to having a {{htmlelement("label")}} for every form element, those labels should be visible, not hidden. Visible labels help _all_ users understand the purpose of a form element. Do not rely on placeholder text, because it disappears as soon as the user starts typing.
## Frame elements must be labeled
Frame elements, both {{htmlelement("iframe")}} and the older, obsolete {{htmlelement("frame")}}, must have a title to describe the contents of the frame. Use the `title` attribute to label a frame element. Without a title, users of assistive technologies have to navigate into the frame in order to understand what it contains, which can be difficult and confusing.
The {{HTMLElement('frame')}} element is no longer part of the HTML specification. Support for it may be dropped by browsers in the future. In addition, it is difficult for screen readers to navigate pages with {{HTMLElement('frame')}} elements. For best accessibility and future maintenance, redesign any pages that use frames to use CSS to achieve a similar layout.
As a best practice, also provide a {{htmlelement("title")}} for the document that is enclosed in the frame, with content identical to the frame's `title` attribute. (This assumes that the enclosed document is under your control; if not, try to match the frame's `title` attribute to the document's title.) Some screen readers replace the contents of the `title` attribute with the contents of the enclosed document's {{htmlelement("title")}}. It's safest and most accessible to provide the same title in both places.
### Example
```html
<iframe
title="MDN Web docs"
width="300"
height="200"
src="https://developer.mozilla.org">
</iframe>
```
## Headings must be labeled
Make sure that your headings have non-empty text content, and are not hidden, such as with CSS `display:none` or `aria-hidden=true`. Users of screen readers rely on headings to understand the structure and content of a document.
Also, be sure you are using [heading elements](/en-US/docs/Web/HTML/Reference/Elements/Heading_Elements) only for actual section headings, and not as a shortcut way to make text stand out. Screen reader users typically "skim" a page's headings, much like sighted users; non-heading text that is marked-up with heading elements can cause confusion.
## Headings should have visible text content
Make sure that your headings have non-empty text content, and are not hidden, such as with CSS `display:none` or `aria-hidden=true`. Users of screen readers rely on headings to understand the structure and content of a document. Do not use heading elements to mark up images or other graphical content.
## Use title attribute to describe `<iframe>` content
Make sure that {{htmlelement("iframe")}} elements have a `title` attribute to describe the contents of the frame. Without a title, users of assistive technologies have to navigate into the frame in order to understand what it contains, which can be difficult and confusing.
As a best practice, also provide a {{htmlelement("title")}} for the document that is enclosed in the frame, with content identical to the frame's `title` attribute. (This assumes that the enclosed document is under your control; if not, try to match the frame's `title` attribute to the document's title.) Some screen readers replace the contents of the `title` attribute with the contents of the enclosed document's {{htmlelement("title")}}. It's safest and most accessible to provide the same title in both places.
## Content with images must be labeled
Provide descriptive text for all contentful (that is, non-decorative) images and image-like elements. This includes SVG images, {{htmlelement("img")}}, {{htmlelement("canvas")}}, {{htmlelement("map")}}, and {{htmlelement("area")}} elements, as well as {{htmlelement("input")}} elements where `type=image` and {{htmlelement("object")}} elements where the `type` starts with `image/`. The typical way to do this is with the `alt` attribute, but for elements that don't allow the `alt` attribute, such as {{htmlelement("canvas")}}, use [`role="img"`](/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/img_role) and [`aria-label`](/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-label) instead. Be sure that the description conveys what is shown in the image.
For `alt` attributes on images which _are_ purely decorative, an empty value can be used to signal to accessibility tools that the element should be ignored.
### Example
```html
<img
src="milkweed.jgp"
alt="Black and white close-up photo of milkweed flowers" />
```
## Interactive elements must be labeled
If an element is intended for users to interact with it, it should have a label. Interactive elements include links ({{htmlelement("a")}}), form elements, buttons, and any element that has a handler for mouse or keyboard events. The way to label an element depends on its type: for form elements, use a {{htmlelement("label")}}; for links, buttons and clickable elements, the text content of the element typically provides the label. If no other option exists for labeling an element, use the [`aria-label`](/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-label) attribute.
## Use label attribute on optgroup elements
In an {{htmlelement("optgroup")}} element, use the `label` attribute to describe the group so that assistive technologies can access it for their users.
### Example
In this example, the `label` attribute on the {{HTMLElement('optgroup')}} elements gives a category name for the group of options.
```html
<label for="dino-select">Choose a dinosaur:</label>
<select id="dino-select">
<optgroup label="Theropods">
<option>Tyrannosaurus</option>
<option>Velociraptor</option>
<option>Deinonychus</option>
</optgroup>
<optgroup label="Sauropods">
<option>Diplodocus</option>
<option>Saltasaurus</option>
<option>Apatosaurus</option>
</optgroup>
</select>
```
## Toolbars must be labeled when there is more than one toolbar
If you define more than one toolbar in a web application using the ARIA `toolbar` role, you must use the [`aria-label`](/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-label) attribute to label each one so that it can be described by assistive technology. It is a good practice to label a toolbar, even if there is only one per page.
### See also
- [W3C ARIA toolbar example](https://www.w3.org/WAI/ARIA/apg/patterns/toolbar/examples/toolbar/)
## Related WCAG success criteria
- [1.1.1 Non-text Content (A)](https://w3c.github.io/wcag/guidelines/22/#non-text-content)
- : All non-text content that is presented to the user has a text alternative that serves the equivalent purpose, except for the situations listed in the above link.
- [2.4.4 Link Purpose (In Context) (A)](https://w3c.github.io/wcag/guidelines/22/#link-purpose-in-context)
- : The purpose of each link can be determined from the link text alone or from the link text together with its programmatically determined link context, except where the purpose of the link would be ambiguous to users in general.
- [2.4.9 Link Purpose (Link Only) (AAA)](https://w3c.github.io/wcag/guidelines/22/#link-purpose-link-only)
- : A mechanism is available to allow the purpose of each link to be identified from link text alone, except where the purpose of the link would be ambiguous to users in general.
|
---
title: Operable
slug: Web/Accessibility/Guides/Understanding_WCAG/Operable
page-type: guide
sidebar: accessibilitysidebar
---
This article provides practical advice on how to write your web content so that it conforms to the success criteria outlined in the **Operable** principle of the Web Content Accessibility Guidelines (WCAG) 2.0 and 2.1. Operable states that user interface components and navigation must be operable.
> [!NOTE]
> To read the W3C definitions for Operable and its guidelines and success criteria, see [Principle 2: Operable — User interface components and navigation must be operable.](https://w3c.github.io/wcag/guidelines/22/#operable)
## Guideline 2.1 — Keyboard Accessible: Make all functionality available from a keyboard
This guideline covers the necessity of making core website functionality available via a keyboard in addition to other means (e.g., mouse), so that users that rely on keyboard controls can access them.
<table class="standard-table">
<thead>
<tr>
<th scope="col">Success criteria</th>
<th scope="col">How to conform to the criteria</th>
<th scope="col">Practical resource</th>
</tr>
</thead>
<tbody>
<tr>
<td>2.1.1 Keyboard (A)</td>
<td>
All functionality should be accessible using keyboard controls, unless
it cannot be done using the keyboard (e.g., freehand drawing). Built-in
controls should be used where possible (e.g., tabbing through form
controls), and you should only build in custom functionality where
needed.
</td>
<td>
See
<a href="/en-US/docs/Learn_web_development/Core/Accessibility/HTML#use_semantic_ui_controls_where_possible"
>Use semantic UI controls where possible</a
>
and
<a
href="/en-US/docs/Learn_web_development/Core/Accessibility/HTML#building_keyboard_accessibility_back_in"
>Building keyboard accessibility back in</a
>
</td>
</tr>
<tr>
<td>2.1.2 No keyboard trap (A)</td>
<td>
<p>
When entering a section of functionality using the keyboard, you
should be able to get out of that section again using <em>only</em> the
keyboard. For example, if you press <kbd>Enter</kbd>/<kbd>Return</kbd>
on a focused button to open an options window, you should be able to
close that window again and return to the main content using the
keyboard.
</p>
<p>
This is very important so that keyboard users do not get trapped on
specific sections of your apps.
</p>
</td>
<td></td>
</tr>
<tr>
<td>2.1.3 Keyboard — all functionality (AAA)</td>
<td>
This is a further step beyond criterion 2.1.1. To achieve AAA
conformance, all functionality should be accessible using keyboard
controls — with no exceptions.
</td>
<td>
See
<a href="/en-US/docs/Learn_web_development/Core/Accessibility/HTML#use_semantic_ui_controls_where_possible"
>Use semantic UI controls where possible</a
>
and
<a
href="/en-US/docs/Learn_web_development/Core/Accessibility/HTML#building_keyboard_accessibility_back_in"
>Building keyboard accessibility back in</a
>
</td>
</tr>
<tr>
<td>
2.1.4 Character Key Shortcuts (A)
</td>
<td>
If a single character key shortcut exists, then at least one of the
following is true: single character key shortcuts can be turned off,
remapped or are only active when the relevant user interface component
is in focus.
</td>
<td>
<a
href="https://www.w3.org/WAI/WCAG21/Understanding/character-key-shortcuts.html"
>Understanding Character Key Shortcuts</a
>
</td>
</tr>
</tbody>
</table>
> [!NOTE]
> Also see the WCAG description for [Guideline 2.1 Keyboard Accessible: Make all functionality available from a keyboard](https://w3c.github.io/wcag/guidelines/22/#keyboard-accessible).
## Guideline 2.2 — Enough Time: Provide users enough time to read and use content
This guideline covers situations in which functionality may have a time limit. For example, purchases sometimes need to be completed within a time limit for security reasons.
<table class="standard-table">
<thead>
<tr>
<th scope="col">Success criteria</th>
<th scope="col">How to conform to the criteria</th>
<th scope="col">Practical resource</th>
</tr>
</thead>
<tbody>
<tr>
<td>2.2.1 Timing is adjustable (A)</td>
<td>
<p>
For functionality with time limits (e.g., completing a hotel or flight
booking often has a time limit), the user should be given controls to
allow them to adjust, extend or turn off the time limit.
</p>
<p>
Exceptions to this are activities with time limits longer than 20
hours, real time events (e.g., live multiplayer games), and any other
activity that requires a time limit and would be invalidated if it
were turned off.
</p>
</td>
<td></td>
</tr>
<tr>
<td>2.2.2 Pausing, stopping, hiding (A)</td>
<td>
<p>
For moving/blinking content that starts automatically, lasts longer
than 5 seconds, and is shown alongside other content, controls should
be provided to pause, stop, or hide it. This does not apply to
moving/blinking content that is essential to the experience. Examples
include scrolling text and videos.
</p>
<p>
For auto-updating information that starts automatically and is shown
alongside other content, controls should be provided to pause, stop,
or hide it, or to control the frequency of updates. This does not
apply to auto-updating content that is essential to the experience.
Examples include carousels or rotating announcements.
</p>
</td>
<td></td>
</tr>
<tr>
<td>2.2.3 No time limits (AAA)</td>
<td>
This builds on criteria 2.2.1, stating that content that wants to pass
AAA conformance should have no time limits.
</td>
<td></td>
</tr>
<tr>
<td>2.2.4 Suppress interruptions (AAA)</td>
<td>
Any interruptions such as alerts or interstitial adverts should have
functionality available to suppress or postpone them, unless it is an
emergency alert.
</td>
<td></td>
</tr>
<tr>
<td>2.2.5 Re-authenticating (AAA)</td>
<td>
If an authentication session expires during usage of a web app, the user
can re-authenticate and continue their usage without losing any data.
</td>
<td></td>
</tr>
<tr>
<td>
2.2.6 Timeouts (AAA)
</td>
<td>
<p>
If there is a timeout (caused by user inactivity) warn users at the
start of a process so they will not be surprised that a timeout exists
(or only allow the timeout to occur after 20 hours of inactivity).
</p>
</td>
<td>
<a href="https://www.w3.org/WAI/WCAG21/Understanding/timeouts.html"
>Understanding Timeouts</a
>
</td>
</tr>
</tbody>
</table>
> [!NOTE]
> Also see the WCAG description for [Guideline 2.2 Enough Time: Provide users enough time to read and use content](https://w3c.github.io/wcag/guidelines/22/#enough-time).
## Guideline 2.3 — Seizures and Physical Reactions: Do not design content in a way that is known to cause seizures or physical reactions
This refers to content that, if not changed, could cause seizures in users with conditions such as epilepsy OR could cause physical reactions (like dizziness) for users with conditions such as vestibular disorders.
<table>
<thead>
<tr>
<th scope="col">Success criteria</th>
<th scope="col">How to conform to the criteria</th>
<th scope="col">Practical resource</th>
</tr>
</thead>
<tbody>
<tr>
<td>2.3.1 Three flashes, or below threshold (A)</td>
<td>Content doesn't contain any aspect that Flashes more than three times per second, or flashing content is below acceptable <a href="https://w3c.github.io/wcag/guidelines/22/#dfn-general-flash-and-red-flash-thresholds">flash and red flash thresholds</a>.</td>
<td></td>
</tr>
<tr>
<td>2.3.2 Three flashes (AAA)</td>
<td>Content doesn't contain any aspect that Flashes more than three times per second.</td>
<td></td>
</tr>
<tr>
<td>2.3.3 Animations from Interactions (AAA)</em></td>
<td>Allow users to disable animations from interactions (unless the animation is essential).</td>
<td><a href="https://w3c.github.io/wcag/guidelines/22/#animation-from-interactions">Understanding Animations from Interactions</a></td>
</tr>
</tbody>
</table>
> [!NOTE]
> Also see the WCAG description for [Guideline 2.3 Seizures and Physical Reactions: Do not design content in a way that is known to cause seizures or physical reactions.](https://w3c.github.io/wcag/guidelines/22/#seizures-and-physical-reactions)
## Guideline 2.4 — Navigable: Provide ways to help users navigate, find content, and determine where they are
The conformance criteria under this guideline relate to ways in which users can be expected to orientate themselves, and find the content and functionality they are looking for on the current page or other pages of the site.
<table class="standard-table">
<thead>
<tr>
<th scope="col">Success criteria</th>
<th scope="col">How to conform to the criteria</th>
<th scope="col">Practical resource</th>
</tr>
</thead>
<tbody>
<tr>
<td>2.4.1 Bypass blocks (A)</td>
<td>
<p>
A mechanism should be provided that allows the user to skip straight
to the main content or functionality available on the page, past the
repeated features (such as the company logo or navigation). This is
often achieved using "skip links" — links put at the top of the page
source that link to the main content and are hidden by CSS.
</p>
<p>
If a proper structure of headings and semantic containers is provided
to navigate with (for example {{htmlelement("section")}},
{{htmlelement("aside")}}, etc.), then an added "skip link" is
not needed.
</p>
</td>
<td><em>Need to add a section on "skip links".</em></td>
</tr>
<tr>
<td>2.4.2 Include page title (A)</td>
<td>
Each web page should include an informative
{{htmlelement("title")}}, the content of which describes the
page's content/purpose.
</td>
<td>
See
<a
href="/en-US/docs/Learn_web_development/Core/Structuring_content/Webpage_metadata#adding_a_title"
>Adding a title</a
>.
</td>
</tr>
<tr>
<td>2.4.3 Logical focus order (A)</td>
<td>
The "tabbing order" of focusable page features (e.g., links, buttons,
form inputs) makes logical sense, meaning that the page is still usable
by non-sighted/keyboard users.
</td>
<td>
See
<a href="/en-US/docs/Learn_web_development/Core/Accessibility/HTML#use_semantic_ui_controls_where_possible"
>Use semantic UI controls where possible</a
>
for general advice on tabbing to controls. If you need to place elements
in an unusual layout, it is better to make sure the source order is
sensible, then use CSS features like
<a href="/en-US/docs/Learn_web_development/Core/CSS_layout/Positioning">positioning</a>
to handle the layout.
</td>
</tr>
<tr>
<td>2.4.4 Link purpose (in context) (A)</td>
<td>
The purpose/destination of a link can be determined from the link text,
or from its surroundings (e.g., the surrounding text). Exceptions are
where the link purpose is ambiguous to <em>all</em> users (see
<a href="https://w3c.github.io/wcag/guidelines/22/#dfn-ambiguous-to-users-in-general"
>ambiguous to users in general</a
>
for a useful explanation of this).
</td>
<td>
See
<a href="/en-US/docs/Learn_web_development/Core/Accessibility/HTML#use_meaningful_text_labels"
>Use meaningful text labels</a
>. Also note that you should minimize instances where multiple copies of
the same text are linked to different places. This can cause problems
for screen reader users, who will often bring up a list of the links out
of context — several links all labelled "click here", "click here",
"click here" would be confusing.
</td>
</tr>
<tr>
<td>2.4.5 Multiple navigation mechanisms (AA)</td>
<td>
<p>
You should provide at least two general navigation mechanisms to find
pages on your website, for example navigation menu, breadcrumb trail,
site search, site map, list of related links, etc.
</p>
<p>
The only exception to this is where a page is one step in a process,
so should only logically have links to the previous and next steps.
</p>
</td>
<td>
Most of these mechanisms can be created using fully supported HTML features, for
example see
<a
href="/en-US/docs/Learn_web_development/Extensions/Forms/HTML5_input_types#search_field"
>Search field</a
>,
<a
href="/en-US/docs/Learn_web_development/Core/Structuring_content/Creating_links#creating_a_navigation_menu"
>Creating a navigation menu</a
>,
<a
href="/en-US/docs/Learn_web_development/Core/Text_styling/Styling_links#styling_links_as_buttons"
>Styling links as buttons</a
>.
</td>
</tr>
<tr>
<td>2.4.6 Headings and labels (AA)</td>
<td>
Heading (e.g., {{htmlelement("Heading_Elements", "<h2>")}}) and
{{htmlelement("label")}} elements clearly describe the purpose
of the content and form elements they are supposed to be describing.
</td>
<td>
<p>
See
<a href="/en-US/docs/Learn_web_development/Core/Accessibility/HTML#use_semantic_ui_controls_where_possible"
>Use semantic UI controls where possible</a
>,
<a href="/en-US/docs/Learn_web_development/Core/Accessibility/HTML#use_meaningful_text_labels"
>Use meaningful text labels</a
>,
<a
href="/en-US/docs/Learn_web_development/Core/Structuring_content/Headings_and_paragraphs"
>The basics of headings and paragraphs</a
>,
<a
href="/en-US/docs/Learn_web_development/Extensions/Forms/How_to_structure_a_web_form#the_label_element"
>The <label> element</a
>.
</p>
<p>
Note that you should avoid duplicating headings or labels (e.g.
multiple instances of "Further information"), unless the structure
allows you to differentiate between them easily.
</p>
</td>
</tr>
<tr>
<td>2.4.7 Visible focus for focusable elements (AA)</td>
<td>
When tabbing through focusable elements such as links or form inputs,
there should be a visual indicator to show you which element currently
has focus. This is usually a dotted or blue outline by default
(depending on browser, platform, etc.), but this can be overridden by
CSS.
</td>
<td>
See
<a
href="/en-US/docs/Learn_web_development/Core/Accessibility/HTML#use_semantic_ui_controls_where_possible"
>Use semantic UI controls where possible</a
>.
</td>
</tr>
<tr>
<td>2.4.8 Location within site (AAA)</td>
<td>
When on a page inside a complex site or set of steps, the user should be
given an indicator of where they are in the site, for example a
breadcrumb trail, sitemap or text such as "Form page 2 of 10".
</td>
<td></td>
</tr>
<tr>
<td>2.4.9 Link purpose (link only) (AAA)</td>
<td>
This criterion builds on 2.4.4, stating that to conform to AAA, the
purpose/destination of a link should be determinable from the link text
alone, even if out of context.
</td>
<td>
See
<a href="/en-US/docs/Learn_web_development/Core/Accessibility/HTML#use_meaningful_text_labels"
>Use meaningful text labels</a
>. Also note that you should minimize instances where multiple copies of
the same text are linked to different places. This can cause problems
for screen reader users, who will often bring up a list of the links out
of context — several links all labelled "click here", "click here",
"click here" would be confusing.
</td>
</tr>
<tr>
<td>2.4.10 Section headings (AAA)</td>
<td>
<p>
As well as creating a useful document structure, headings should also
accurately describe and break up content areas into logical sections.
</p>
<p>
Note that this criterion refers to headings and titles in general web
content (e.g., headings within text content). Headings and titles for
user interfaces are a special case covered in criterion 4.1.2.
</p>
</td>
<td>
<p>
See
<a
href="/en-US/docs/Learn_web_development/Core/Structuring_content/Headings_and_paragraphs"
>The basics of headings and paragraphs</a
>.
</p>
</td>
</tr>
<tr>
<td> 2.4.11 Focus not obscured (Minimum) (AA)</td>
<td>
<p> When a user interface component receives keyboard focus, the component is not entirely hidden due to containing author-created content.</p>
<p> <strong>Note:</strong> If the interface's content can be repositioned by the user, then only the initial position of the user-movable content is considered for testing to conform to this standard. Also, content opened by the user may obscure the component receiving focus. Furthermore, if the user can reveal the focused component without changing keyboard focus, the component with focus is not considered hidden for conformance and testing purposes.</p>
</td>
<td>
<p> Check out <a href="https://www.w3.org/WAI/WCAG22/Understanding/focus-not-obscured-minimum">Understanding focus not obscured (Minimum)</a> to learn more about this standard.</p>
</td>
</tr>
<tr>
<td> 2.4.12 Focus not obscured (Enhanced) (AAA) </td>
<td>
<p> Follows the rules as 2.4.11 except when a user interface component receives focus, no part of the component can be hidden by author-created content. If the interface is configurable, only the initial positions of user-movable content are considered for testing and meeting of this standard.</p>
</td>
<td>
<p> Check out <a href="https://www.w3.org/WAI/WCAG22/Understanding/focus-not-obscured-enhanced">Understanding focus not obscured (Enhanced) (Level AAA)</a> to learn more about this standard.</p> </td>
</td>
</tr>
<tr>
<td> 2.4.13 Focus appearance (AAA)</td>
<td>
<p>When the keyboard focus indicator is visible, the area of the focus indicator meets all the following:</p>
<ul>
<li>Must be at least as large as the area of a <code>2px</code> thick perimeter of the unfocused component or sub-component, which includes component's content, border, and background, excluding outer shadows or glow effects.</li>
<li>Needs to have a contrast ratio of at least 3:1 between the same pixels in the focused and unfocused states</li>
</ul>
<p> The exceptions to this are:</p>
<ul>
<li>The focus indicator is determined by the user and cannot be adjusted by the author.</li>
<li>The focus indicator and the indicator's background color are not modified by the author.</li>
</ul>
</td>
<td>
<p> Check out <a href="https://www.w3.org/WAI/WCAG22/Understanding/focus-appearance.html">Understanding focus appearance (Level AAA)</a> to learn more about this standard.</p>
</td>
</tr>
</tbody>
</table>
> [!NOTE]
> Also see the WCAG description for [Guideline 2.4 Navigable: Provide ways to help users navigate, find content, and determine where they are.](https://w3c.github.io/wcag/guidelines/22/#navigable)
## Guideline 2.5 Input Modalities: Make it easier for users to operate functionality through various inputs beyond keyboard
The conformance criteria under this guideline ensures that users are able to interact with digital technology using different input methods beyond a keyboard or mouse (including touchscreen, voice, device motion, or alternative input devices).
<table>
<thead>
<tr>
<th scope="col">Success criteria</th>
<th scope="col">How to conform to the criteria</th>
<th scope="col">Practical resource</th>
</tr>
</thead>
<tbody>
<tr>
<td>2.5.1 Pointer Gestures (A)</em></td>
<td>All functionality that can be operated with a pointer can be operated with single-point actions. Path-based or multi-point gestures are not required to operate any functionality. Exceptions exist.</td>
<td><a href="https://www.w3.org/WAI/WCAG21/Understanding/pointer-gestures.html">Understanding Pointer Gestures</a></td>
</tr>
<tr>
<td>2.5.2 Pointer Cancellation (A)</em></td>
<td>For functionality that can be operated using a single-pointer at least one of the following is true: no down-event, abort/undo, up reversal or essential.</td>
<td><a href="https://www.w3.org/WAI/WCAG21/Understanding/pointer-cancellation.html">Understanding Pointer Cancellation</a></td>
</tr>
<tr>
<td>2.5.3 Label in Name (A)</em></td>
<td>For each user interface component that includes a visible text label, make sure the accessible name matches (or includes) the visible text in the label.</td>
<td><a href="https://www.w3.org/WAI/WCAG21/Understanding/label-in-name.html">Understanding Label in Name</a></td>
</tr>
<tr>
<td>2.5.4 Motion Actuation (A)</em></td>
<td>Ensure that for functionality that can be triggered by a) device motion (like shaking, tilting) or b) user gestures detected by device sensors (including a camera) that both of the following are true: 1) motion actuation can be disabled, and 2) the functionality can be operated without using device motion or user gestures. Exceptions exist.</td>
<td><a href="https://www.w3.org/WAI/WCAG21/Understanding/motion-actuation.html">Understanding Motion Actuation</a></td>
</tr>
<tr>
<td>2.5.5 Target Size (AAA)</td>
<td>The size of an actionable item's touch target must be at least 44 CSS pixels in both width and height. Exceptions exist.</td>
<td><a href="https://www.w3.org/WAI/WCAG21/Understanding/target-size.html">Understanding Target Size</a></td>
</tr>
<tr>
<td>2.5.6 Concurrent Input Mechanisms (AAA)</td>
<td>Make sure people can use and switch between different modes of input when interacting with digital content including touchscreen, keyboard, mouse, voice commands, or alternative input devices. An essential exception exists. </td>
<td><a href="https://www.w3.org/WAI/WCAG21/Understanding/concurrent-input-mechanisms.html">Understanding Concurrent Input Mechanism</a></td>
</tr>
<tr>
<td> 2.5.8 Target size minimum (AA)</td>
<td> Target size for pointer inputs should be at least <code>24px</code> wide by <code>24px</code> tall except for the following areas:
<ul>
<li> <strong>Spacing:</strong>Targets that are less than <code>24px x 24px</code> are positioned so that if a <code>24px</code> diameter circle is centered on each target's bounding box, the circles do not intersect with any other target or the circle for another undersized target.</li>
<li> <strong>Equivalent:</strong> A separate control that achieves the same function that meets this standard is available on the same page.</li>
<li> <strong>Inline:</strong> The target is located within a line of text with its size constrained by the line height or surrounding non-target text.</li>
<li> <strong>User agent control:</strong> The target's size is determined by the user agent and has not been modified by the author.</li>
<li> <strong>Essential:</strong> A particular presentation of the target is essential or legally required for the information being conveyed.</li>
</ul>
<td> Check out <a href="https://www.w3.org/WAI/WCAG22/Understanding/target-size-minimum.html">Understanding target size minimum</a> </td>
</tr>
</tr>
</tbody>
</table>
> [!NOTE]
> Also see the WCAG description for [Guideline 2.5: Input Modalities: Make it easier for users to operate functionality through various inputs beyond keyboard.](https://w3c.github.io/wcag/guidelines/22/#input-modalities)
## See also
- [WCAG](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG)
1. [Perceivable](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Perceivable)
2. Operable
3. [Understandable](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Understandable)
4. [Robust](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Robust)
|
---
title: Understandable
slug: Web/Accessibility/Guides/Understanding_WCAG/Understandable
page-type: guide
sidebar: accessibilitysidebar
---
This article provides practical advice on how to write your web content so that it conforms to the success criteria outlined in the **Understandable** principle of the Web Content Accessibility Guidelines (WCAG) 2.0 and 2.1. Understandable states that information and the operation of user interface must be understandable.
> [!NOTE]
> To read the W3C definitions for Understandable and its guidelines and success criteria, see [Principle 3: Understandable — Information and the operation of user interface must be understandable](https://w3c.github.io/wcag/guidelines/22/#understandable).
## Guideline 3.1 — Readable: Make text content readable and understandable
This guideline focuses on making text content as understandable as possible.
<table class="standard-table">
<thead>
<tr>
<th scope="col">Success criteria</th>
<th scope="col">How to conform to the criteria</th>
<th scope="col">Practical resource</th>
</tr>
</thead>
<tbody>
<tr>
<td>3.1.1 Language of Page (A)</td>
<td>
The default human language of each web page should be detectable via
code. This is essential for purposes like making sure the reader has
arrived at a page written in a language suitable for them. The simplest
way to achieve this is to set the <a href="/en-US/docs/Web/HTML/Reference/Global_attributes/lang">lang</a>
attribute on the page's {{htmlelement("html")}} element, giving
it a value equal to the language code that best represents the language
the page is written in.
</td>
<td>
See
<a
href="/en-US/docs/Learn_web_development/Core/Structuring_content/Webpage_metadata#setting_the_primary_language_of_the_document"
>Setting the primary language of the document</a
>.
</td>
</tr>
<tr>
<td>3.1.2 Language of Parts (AA)</td>
<td>
<p>
In cases where the content of a page includes words or phrases that
are in a different language to the primary language, use the
<a href="/en-US/docs/Web/HTML/Reference/Global_attributes/lang">lang</a> attribute on an element wrapped
around the term in question (e.g., a {{htmlelement("span")}}
if no semantic element is available) to set an appropriate language
for it.
</p>
<p>
You don't need to set a different language for words or phrases that
are the same regardless of language (for example proper names,
technical terms that aren't part of a specific language).
</p>
</td>
<td></td>
</tr>
<tr>
<td>3.1.3 Unusual Words (AAA)</td>
<td>
Where technical terms, jargon, or idioms/slang are used, definitions
should be provided for such phrases/words. Your site should provide a
glossary that contains definitions of such words/terms that you can then
link to when they appear, or at the very least provide definitions
somewhere in the surrounding text, or in a
<a
href="/en-US/docs/Learn_web_development/Core/Structuring_content/Lists#description_lists"
>description list</a
>
at the bottom of the page.
</td>
<td></td>
</tr>
<tr>
<td>3.1.4 Abbreviations (AAA)</td>
<td>
<p>
Where abbreviations are used, you should provide an expansion of them,
or a definition as required.
</p>
<p>
The {{htmlelement("abbr")}} element is often thought of as
the preferred way to provide an expansion for an abbreviation — it
takes a <a href="/en-US/docs/Web/HTML/Reference/Global_attributes/title">title</a> attribute that contains the
expansion, and this appears when the acronym is moused over. However,
the title contents are not accessible via keyboard, nor are they
reliably read out by screen readers. A better way to handle this is to
again provide links to glossary pages containing the acronym expansion
and explanation, or at the very least include them in the surrounding
text in context.
</p>
</td>
<td>
See
<a
href="/en-US/docs/Learn_web_development/Core/Structuring_content/Advanced_text_features#abbreviations"
>Abbreviations</a
>.
</td>
</tr>
<tr>
<td>3.1.5 Reading Level (AAA)</td>
<td>
<p>
If text is provided that requires a higher reading level that lower
secondary education level (typically children around 11-14 years old),
provide supplementary explainer material to help people who can't read
it, or provide an alternative version that is written at lower
secondary level.
</p>
<p>
This doesn't mean that all subject matter should be understood by
everyone, but that the style of writing should be accessible by
everyone. It is better to just write all content at lower secondary
level, even technical documentation like programming tutorials, unless
there is a good reason not to (e.g., an alternative style for poetic
effect), or they have to be written in a strict style (e.g., W3C
specs).
</p>
</td>
<td></td>
</tr>
<tr>
<td>3.1.6 Pronunciation (AAA)</td>
<td>
<p>
A mechanism should be provided to give users access to pronunciation
of words where they are is needed to understand the content fully.
</p>
<p>
The HTML {{htmlelement("audio")}} element can be used to
create a control that allows the reader to play back an audio file
containing the correct pronunciation, and it also makes sense to
include a textual pronunciation guide after difficult words, in the
same way that you find in dictionary entries.
</p>
</td>
<td>
See
<a
href="/en-US/docs/Learn_web_development/Core/Structuring_content/HTML_video_and_audio"
>Video and audio content</a
>, and
<a
href="https://www.oxfordlearnersdictionaries.com/us/about/pronunciation_english.html"
>Pronunciation Guide for English Dictionary</a
>
</td>
</tr>
</tbody>
</table>
> [!NOTE]
> Also see the WCAG description for [Guideline 3.1 Readable: Make text content readable and understandable](https://w3c.github.io/wcag/guidelines/22/#readable).
## Guideline 3.2 — Predictable: Make Web pages appear and operate in predictable ways
This guideline focuses on making user interfaces intuitive and understandable.
<table class="standard-table">
<thead>
<tr>
<th scope="col">Success criteria</th>
<th scope="col">How to conform to the criteria</th>
<th scope="col">Practical resource</th>
</tr>
</thead>
<tbody>
<tr>
<td>3.2.1 On Focus (A)</td>
<td>
<p>
When a control or other page feature receives focus, it should not
change the context in a way that may confuse or disorientate the user.
</p>
<p>
This is a matter of sensible design — people don't want interfaces to
surprise them; they want things to be intuitive and behave as
expected. For example, focusing a navigation menu option should not
change the displayed page — it should be activated before the display
changes.
</p>
</td>
<td>
<code>Element</code>'s {{domxref("Element.focus_event", "focus")}} event contains some
useful information. Also see
<a
href="/en-US/docs/Learn_web_development/Core/Accessibility/HTML#building_keyboard_accessibility_back_in"
>Building keyboard accessibility back in</a
>
for some useful implementation ideas.
</td>
</tr>
<tr>
<td>3.2.2 On Input (A)</td>
<td>
<p>
When data is inputted into a control, or a setting is changed, context
should not be changed unexpectedly. The user should be warned/advised
of the impending change before it occurs.
</p>
<p>
Again, sensible design should be implemented. For example, if pressing
a button causes the application to exit the current view, the user
should be asked to confirm this action, save their work if
appropriate, etc.
</p>
</td>
<td>
The {{domxref("Element/input_event", "input")}} event is useful here.
</td>
</tr>
<tr>
<td>3.2.3 Consistent Navigation (AA)</td>
<td>
<p>
Navigation menu/control style and positioning should be consistent
between different pages or views of a web page, and the existing items
should appear in the same order, even if for example new items are
added. If the user has initiated a change, e.g., choosing a different
color scheme or position for the navigation, their choice should be
respected across all pages.
</p>
<p>
Again, sensible design — make the navigation controls the same across
all pages or views.
</p>
</td>
<td>
See
<a href="/en-US/docs/Learn_web_development/Core/Accessibility/HTML#structure_page_sections_logically"
>Structure page sections logically</a
>
for information on modern markup for layouts. See also
<a
href="/en-US/docs/Learn_web_development/Core/Text_styling/Styling_links#styling_links_as_buttons"
>Styling links as buttons</a
>
for a useful accessible navigation menu example.
</td>
</tr>
<tr>
<td>3.2.4 Consistent Identification (AA)</td>
<td>
<p>
Controls or components that have the same functionality should be
identified in the same way across different pages or views. A currency
converter appearing on every page of a world travel site for example
should be exactly the same, semantically and in terms of labels.
</p>
<p>Again, sensible design!</p>
</td>
<td>
"Labels" can refer to descriptive information in text content, or HTML
form labels. See
<a href="/en-US/docs/Learn_web_development/Core/Accessibility/HTML#use_meaningful_text_labels"
>Use meaningful text labels</a
>
for more information.
</td>
</tr>
<tr>
<td>3.2.5 Change on Request (AAA)</td>
<td>
<p>
Changes in context that could possibly confuse or disorient users
should only occur only when requested by the user, OR the user should
be able to turn them off.
</p>
<p>
If you need to have something that significantly changes the current
view (e.g., content or controls), let the user control when they want
that change to occur (e.g., what page to show, when to advance to the
next photo in the gallery...)
</p>
<p>
If you need to have something like a carousel on a page, provide an
option to stop it automatically advancing. Better to avoid such
functionality if possible.
</p>
</td>
</tr>
<tr>
<td> 3.2.6 Consistent help (A)</td>
<td> <p> Web pages that contain help mechanisms, including self-help options and human contact details, that are repeated on multiple web pages, need to place those mechanisms in the same order on all pages, unless a change is initiated by the user.</p>
<td> <p> Check out the <a href="https://www.w3.org/WAI/WCAG22/Understanding/consistent-help">consistent help documentation</a> for this standard to learn more. </p>
</td>
</td>
<tr>
</tr>
</tbody>
</table>
> [!NOTE]
> Also see the WCAG description for [Guideline 3.2 Predictable: Make Web pages appear and operate in predictable ways](https://w3c.github.io/wcag/guidelines/22/#predictable).
## Guideline 3.3 — Input Assistance: Help users avoid and correct mistakes
This guideline centers around helping users enter correct information when required with the minimum of mistakes.
<table class="standard-table">
<thead>
<tr>
<th scope="col">Success criteria</th>
<th scope="col">How to conform to the criteria</th>
<th scope="col">Practical resource</th>
</tr>
</thead>
<tbody>
<tr>
<td>3.3.1 Error Identification (A)</td>
<td>
<p>
When a user is filling out a form or choosing between options, any
error that is detected should be clearly reported to the user, along
with the form control that the error relates to.
</p>
<p>
It is advisable to implement client-side error detection and handling,
via HTML form validation features, and/or JavaScript, whatever is
best for your situation. When an error is detected, an intuitive error
message should be shown next to the form input that is at fault to
help the user correct their inputs. For screen reader users, you can
use aria live regions to alert the user to a change on the page.
</p>
<div class="note notecard">
<p>
<strong>Note:</strong> Server-side validation should <em>always</em> be
used alongside client-side validation. Client-side validation is too
easy to turn off or otherwise get around, so it can't be relied on
alone.
</p>
</div>
</td>
<td>
See
<a href="/en-US/docs/Learn_web_development/Extensions/Forms/Form_validation"
>Form data validation</a
>
for comprehensive validation information, and
<a
href="/en-US/docs/Learn_web_development/Core/Accessibility/WAI-ARIA_basics#dynamic_content_updates"
>WAI-ARIA: Dynamic content updates</a
>
for information on live regions.
</td>
</tr>
<tr>
<td>3.3.2 Labels or Instructions (A)</td>
<td>
<p>
Clear instructions should be provided when data input is required.
When a short instruction or prompt is required, you can use
{{htmlelement("label")}} elements for single inputs like name
or age, a combination or {{htmlelement("label")}}s and
{{htmlelement("fieldset")}}s/{{htmlelement("legend")}}s
for multiple inputs that go together (like the elements of a date of
birth or postal address).
</p>
<p>
When more complex explanation is required, you can always include
explanatory paragraphs too, or maybe you need to try to make your
forms more intuitive.
</p>
</td>
<td>
<ul>
<li>
<a
href="/en-US/docs/Learn_web_development/Core/Accessibility/HTML#use_meaningful_text_labels"
>Use meaningful text labels</a
>
</li>
<li>
<a href="/en-US/docs/Learn_web_development/Extensions/Forms/How_to_structure_a_web_form"
>How to structure an HTML form</a
>
</li>
<li>
<a
href="/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Text_labels_and_names"
>Text labels and names</a
>
</li>
</ul>
</td>
</tr>
<tr>
<td>3.3.3 Error Suggestion (AA)</td>
<td>
<p>
When an error is detected and suggestions for correction are known,
provide these to the user (e.g., suggesting alternatives when the user
is choosing a user name and has selected one that is already taken),
unless doing so would cause a security issue (e.g., when entering a
password) or context problem (e.g., they are trying to answer a
question in a quiz app).
</p>
<p>
In such cases, when this is appropriate, you'll probably use a
combination of JavaScript and server-side functionality to check if
the entry is correct, and if not, what viable suggestions can be given
to the user. Such suggestions should be displayed usefully in context,
just like error messages (see 3.3.1).
</p>
</td>
<td>No tutorial suggestions yet.</td>
</tr>
<tr>
<td>3.3.4 Error Prevention (Legal, Financial, Data) (AA)</td>
<td>
<p>
In the case of forms involved with entry of sensitive data (such as
legal agreements, e-commerce transactions, or personal data), at least
one of the following should be true:
</p>
<ul>
<li>Submissions are reversible.</li>
<li>
Data is checked for errors, and the user is given an opportunity to
correct them.
</li>
<li>
A mechanism is available for confirming and correcting information
before final submission.
</li>
</ul>
</td>
<td>
<p>
<strong>Reversible</strong> — for any view where data can be entered,
provide an equivalent view that allows you to edit or even delete an
entry, as appropriate (for example, see
<a href="/en-US/docs/Learn_web_development/Extensions/Server-side/Django">Django web framework</a
>).
</p>
<p>
<strong>Checking data</strong> — as covered in 3.3.1, a combination of
client-side and server-side validation should be used to detect errors
and display helpful messages to the user to allow them to correct
their inputs.
</p>
<p>
<strong>Confirm and correct</strong> — where appropriate, after
filling in a series of form fields to perform a task (such as buying a
product), the user should be shown a confirmation screen where they
can review their inputs and correct anything that doesn't look right.
This pattern is commonly used on e-commerce sites like Amazon.
</p>
</td>
</tr>
<tr>
<td>3.3.5 Context-sensitive help is available (AAA)</td>
<td>
Provide instructions and other appropriate cues in context to aid form
completion and submission.
</td>
<td>
This really just builds on 3.3.1 and other similar criteria but requires
more thorough contextual help information and services, e.g., providing a
dedicated link to a help page or service on each page, providing
examples showing what successful completion should look like.
</td>
</tr>
<tr>
<td>3.3.6 Error Prevention (All) (AAA)</td>
<td>
This principle builds on 3.3.4, extending its requirements to all user
input situations, not just ones involving sensitive data.
</td>
<td>Again, see 3.3.4.</td>
</tr>
<tr>
<td> 3.3.7 Redundant entry (A) </td>
<td>
Information that is required that was previously entered or provided by the user in the same process or user flow is either auto-populated or made selectable to the user from a list of options, unless re-entering the information is essential or required for security reasons, or if the information is no longer valid.
</td>
<td>Check out <a href="https://www.w3.org/WAI/WCAG22/Understanding/redundant-entry">Understanding redundant entry</a> to learn more.</td>
</tr>
<tr>
<td> 3.3.8 Accessible authentication (Minimum) (AA)
</td>
<td>
Cognitive function tests, like remembering a password, are not required for any step in an authentication process unless an alternative is provided, such as an object or personal content (e.g., images, videos, and audio) recognition, or a mechanism to assist (e.g., copy and paste and autosave passwords).
</td>
<td> Check out the <a href="https://www.w3.org/WAI/WCAG22/Understanding/accessible-authentication-minimum"> accessible authentication documentation</a> for this standard to learn more. </td>
</tr>
<tr>
<td> 3.3.9 Accessible Authentication (Enhanced) (AAA) </td>
<td>
A cognitive function test, like remembering a password, must not be required for any step in an authentication process without providing an alternative that does not rely on a cognitive function test or provides a mechanism to assist the user in completing the cognitive function test. Authentication tests that require the user to recognize objects or identify non-text content the user provided to the website are allowed.
</td>
<td> Check out the <a href="https://www.w3.org/WAI/WCAG22/Understanding/accessible-authentication-enhanced">enhanced accessible authentication documentation (AAA)</a> to learn more.</td>
</tr>
</tbody>
</table>
> [!NOTE]
> Also see the WCAG description for [Guideline 3.3 Input Assistance: Help users avoid and correct mistakes](https://w3c.github.io/wcag/guidelines/22/#input-assistance).
## See also
- [WCAG](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG)
1. [Perceivable](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Perceivable)
2. [Operable](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Operable)
3. Understandable
4. [Robust](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Robust)
|
---
title: Accessibility information for web authors
short-title: Information for web authors
slug: Web/Accessibility/Guides/Information_for_Web_authors
page-type: guide
sidebar: accessibilitysidebar
---
This document lists guidelines and regulations, how-to's, and tools for checking and repairing accessibility problems with websites.
## Guidelines and Regulations
- [<abbr>ARIA</abbr> Authoring Practices Guide (<abbr>APG</abbr>)](https://www.w3.org/WAI/ARIA/apg/)
- : Guide to accessibility semantics defined by the Accessible Rich Internet Application (<abbr>ARIA</abbr>) specification to create accessible web experiences. Describes how to apply accessibility semantics to common design patterns and widgets, providing design patterns and functional examples.
- [Web Content Accessibility Guidelines (<abbr>WCAG</abbr>)](https://www.w3.org/WAI/standards-guidelines/wcag/)
- : Another important set of guidelines from the W3C _Web Accessibility Initiative (<abbr>WAI</abbr>)_. The European Union is looking to base their upcoming accessibility regulations on these guidelines. These guidelines are discussed on the [<abbr>WAI</abbr> interest group discussion list](https://www.w3.org/WAI/about/groups/waiig/#mailinglist).
- [ARIA on this site](/en-US/docs/Web/Accessibility/ARIA)
- : <abbr>MDN</abbr> guide to all the [ARIA roles](/en-US/docs/Web/Accessibility/ARIA/Reference/Roles) and [ARIA properties](/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes), including best practices, related roles and properties, and examples.
## How-to's
- [Accessibility for teams](https://digital.gov/guides/accessibility-for-teams/)
- : A brief guide from the U.S. General Services administration's Technology Transformation Services covering several accessibility topics with links to "how-to" videos and to related WCAG references.
- [Accessible Web Page Authoring](https://www.ibm.com/able/requirements/requirements/)
- : IBM has made their accessibility requirements that need to be met public and interactive.
## Automated Checking & Repair
Use a tool to quickly check for common errors in your browser.
- [HTML CodeSniffer](https://squizlabs.github.io/HTML_CodeSniffer/)
- [aXe](https://chromewebstore.google.com/detail/axe-devtools-web-accessib/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US)
- [Lighthouse Accessibility Audit](https://developer.chrome.com/docs/lighthouse/overview/)
- [Accessibility Insights](https://accessibilityinsights.io/)
- [<abbr>WAVE</abbr>](https://wave.webaim.org/extension/)
Tools to integrate into your build process, programmatically adding accessibility tests, so you can catch errors as you develop your web application:
- [axe-core](https://github.com/dequelabs/axe-core)
- [jsx-a11y](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y)
- [Lighthouse Audits](https://github.com/GoogleChrome/lighthouse/blob/main/docs/readme.md#using-programmatically)
- [AccessLint.js](https://github.com/accesslint/accesslint.js/tree/master)
{{glossary("Continuous integration")}} tools to find accessibility issues in your GitHub pull requests:
- [AccessLint](https://accesslint.com/)
While best to test your web applications with real users, you can simulate color blindness, low vision, low and contrast, and zooming. You should always test your site with out a mouse and touch to test keyboard navigation. You may also want to try your site using voice commands. Try disabling your mouse and using browser extensions like [Web Disability Simulator](https://chromewebstore.google.com/detail/web-disability-simulator/olioanlbgbpmdlgjnnampnnlohigkjla)
|
---
title: Web accessibility for seizures and physical reactions
short-title: Preventing seizures and physical reactions
slug: Web/Accessibility/Guides/Seizure_disorders
page-type: guide
sidebar: accessibilitysidebar
---
This article introduces concepts behind making web content accessible for those with vestibular disorders, and how to measure and prevent content leading to seizures and/or other physical reactions.
## Overview
### Seizures
Seizures caused by light are known as photosensitive epilepsy. Content that flickers, flashes, or blinks can trigger photosensitive epilepsy. Web technologies that use video, animated GIFs, animated PNGs, animated SVGs, {{Glossary("Canvas")}}, and CSS or JavaScript animations can all produce content that may induce seizures or other incapacitating physical reactions. Certain visual patterns, especially stripes, can also cause physical reactions even though they are not animated. Photosensitive epilepsy is actually a kind of "reflex epilepsy"—seizures occurring in response to a trigger. In the case of photosensitive epilepsy, seizures are triggered specifically by flashing lights, but other types of reflex epilepsies may be triggered by the act of reading or by noises. Patterns and images can also trigger epilepsy.
The fact that static images may cause seizures and other disorders is documented in articles such as ["Gamma Oscillations and photosensitive epilepsy"](https://linkinghub.elsevier.com/retrieve/pii/S0960982217304062), where it is noted "_Certain visual images, even in the absence of motion or flicker, can trigger seizures in patients with photosensitive epilepsy_". The Epilepsy Foundation, in its article, ["Shedding Light on Photosensitivity, One of Epilepsy's Most Complex Conditions"](https://www.epilepsy.com/stories/shedding-light-photosensitivity-one-epilepsys-most-complex-conditions) talks about static images and patterns: "_Static or moving patterns of discernible light and dark stripes have the same effect as flashing lights because of the alternation of dark and bright areas."_ The Epilepsy Foundation of America Working Group is able to "quantify" the problem a little: _"A pattern with the potential for provoking seizures contains clearly discernible stripes, numbering more than five light-dark pairs of stripes in any orientation_". In addition to stripes, checkered patterns have also been known to cause photosensitive seizures, according to [Cedars-Sinai](https://www.cedars-sinai.org/health-library/diseases-and-conditions/p/photosensitive-seizures.html).
Although static images are possible as triggers, they are less consistent. The trigger that is well established and strong is flashing/strobe lights. Dr. Selim Benbadis of USF's Comprehensive Epilepsy Program notes, _"The only thing that is really documented is flashing lights, which can trigger seizures in patients with photosensitive epilepsy. Only a few types of epilepsies are photosensitive though, and the vast majority of epilepsies are not."_ In addition to seizures brought about by photosensitivity, listening to certain pieces of music can also trigger what are called musicogenic seizures, although these types of seizures seem to be much more rare. For a great introduction on the topic of musicogenic seizures, visit Epilepsy Ontario's web page on [Musicogenic Seizures](https://epilepsyontario.org/musicogenic-seizures/).
Seizures and epilepsy are not the same. In its article ["A Revised Definition of Epilepsy"](https://www.epilepsy.com/stories/revised-definition-epilepsy), the Epilepsy Foundation notes that "_a seizure is an event and epilepsy is the disease involving recurrent unprovoked seizures_." According to the Epilepsy Foundation's page ["How Serious Are Seizures?"](https://www.epilepsy.com/what-is-epilepsy/understanding-seizures/how-serious-are-seizures), _"Sudden unexpected death in epilepsy (SUDEP) is likely the most common disease-related cause of death in with epilepsy. It is not frequent but it is a very real problem and people need to be aware of its risk"_.
The point is, seizures most definitely can be and are fatal, and developers and designers are incredibly important for making the web a safer place for those with sensitivities to photosensitive or musicogenic triggers.
Seizures can be fatal, but even the ones that are "only" debilitating can be of such severity that they render the user incapacitated. Other disorders, such as disorientation, nausea, vomiting, and more can also be so severe that the user is unable to function. The Epilepsy Foundation's article, ["Photosensitivity and Seizures"](https://www.epilepsy.com/what-is-epilepsy/seizure-triggers/photosensitivity), provides a list of triggers that may cause seizures in photosensitive people; here's an excerpt from that list:
- Television screens or computer monitors due to the flicker or rolling images.
- Certain video games or TV broadcasts containing rapid flashes or alternating patterns of different colors.
- Intense strobe lights like visual fire alarms.
- Natural light, such as sunlight, especially when shimmering off water, flickering through trees or through the slats of Venetian blinds.
- Certain visual patterns, especially stripes of contrasting colors.
That same article continues that many factors must combine to trigger the photosensitive reaction. Of note is that it includes the wavelength of light as a possible factor; wavelengths in the red part of the spectrum seem to be especially problematic. In the article, ["Understanding WCAG 2.0 Three Flashes or Below Threshold"](https://www.w3.org/TR/UNDERSTANDING-WCAG20/seizure-does-not-violate.html) notes generally that: _"Individuals who have photosensitive seizure disorders can have a seizure triggered by content that flashes at certain frequencies for more than a few flashes"_ and goes on to note, very specifically that: "_People are even more sensitive to red flashing than to other colors, so a special test is provided for saturated red flashing_".
You don't even need an image or video to cause harm. A {{HTMLElement('div')}} element set to change color and luminosity at high frequency, easily done via JavaScript, can cause real harm. And, flickering can occur everywhere. For example, "spinners" commonly used to display while pages load can easily "flicker" while spinning.
Additional concerns exist for individuals with motor-skill problems. For example, the page for Trace Research & Development Center's [Photosensitive Epilepsy Analysis Tool](https://trace.umd.edu/peat/) notes that _"Photosensitive seizures can be provoked by certain types of flashing in web or computer content, including mouse-overs that cause large areas of the screen to rapidly flash on and off repeatedly"_.
### Other physical reactions
Nausea, vertigo (or dizziness), and disorientation are very nonspecific symptoms associated with all kinds of diseases and not particularly suggestive of seizures (except maybe disorientation, which is seen in seizures). However, seizures are not the only adverse physical response possible from flashing, flickering, blinking, and other such stimuli. In 1997, a Japanese cartoon featured an animated "virus bomb". Some of the children watching the cartoon reacted by having seizures, others by suffering nausea, shaking, and vomiting blood. The reactions from the children were so severe, they had to be rushed to the emergency room. The physical disorders listed below are all possible consequences: each of these physical reactions may be so severe as to be incapacitating.
- Seizures
- Vestibular Disorders
- Migraines
- Nausea
- Vomiting
## Flashing, blinking, & flickering
Although "flashing" and "blinking" are sometimes used interchangeably, they are not the same. According to the W3C, blinking is a distraction problem, whereas flashing refers to content that occurs more than 3 times per second, and which is sufficiently large and bright. [Section 508](https://www.section508.gov/content/guide-accessible-web-design-development/#flashing) prohibits flickering effects with a frequency greater than 3 Hz (flickers per second) and lower than 55 Hz. The Epilepsy Foundation's article ["Shedding Light on Photosensitivity, One of Epilepsy's Most Complex Conditions"](https://www.epilepsy.com/stories/shedding-light-photosensitivity-one-epilepsys-most-complex-conditions) notes that _"Generally, flashing lights between the frequencies of five to 30 flashes per second (Hertz) are most likely to trigger seizures. In order to be safe, the consensus recommends that photosensitive individuals should not be exposed to flashes greater than three per second."_ For some people, however, flashing/blinking can cause symptoms at less than 3 Hz.
It's important to note that not all flashing and blinking is bad. NASA, in its document titled, ["Blinking, Flashing, and Temporal Response"](https://web.archive.org/web/20250215094718/https://colorusage.arc.nasa.gov/flashing.php) notes that blinking and flashing can be powerful tools for drawing attention—as is necessary for warning buttons (this assumes that users can still see the screen while elements are flashing, which is not always true). For some users, blinking buttons also caution that they must be used sparingly, and with care. As it applies to web design, systems that alert company employees to danger by "hijacking" the screen to provide a flashing warning of emergency need to take into consideration the rate, size, and luminosity changes on the screen as these warnings are flashed.
### Flashing and flickering—how is danger quantified?
According to the article ["Photic- and pattern-induced seizures: expert consensus of the Epilepsy Foundation of America Working Group",](https://onlinelibrary.wiley.com/doi/epdf/10.1111/j.1528-1167.2005.31405.x) _"A flash is a potential hazard if it has luminance ≥20 cd/m<sup>2</sup>, occurs at a frequency of ≥3 Hz, and occupies a solid visual angle of ≥0.006 steradians (approximately 10% of the central visual field or 25% of screen area at typical viewing distances)."_
How far is a typical viewing distance? The recommendation considered for a typical viewing distance at the time of writing was "_the area can be taken as applying to an area >25% of the area of a television screen, assuming standard viewing distances of ≥2 m (∼9 feet)"_. Much has changed since that time, and we are now much closer to our screen.
Certain colors, and/or combinations of colors, also matter. ["Certain Colors More Likely To Cause Epileptic Fits, Researchers Find"](https://www.sciencedaily.com/releases/2009/09/090925092858.htm) notes that _"…complexities underlying brain dynamics could be modulated by certain color combinations more than the others, for example, red-blue flickering stimulus causes larger cortical excitation than red-green or blue-green stimulus."_
### Flashing & flashing red
[WCAG 2.3.1 general flash and red flash thresholds](https://www.w3.org/WAI/WCAG21/Understanding/three-flashes-or-below-threshold.html) are defined as follows:
- A **general flash** is defined as a pair of opposing changes in [relative luminance](https://w3c.github.io/wcag/guidelines/22/#dfn-relative-luminance) of 10% or more of the maximum relative luminance where the relative luminance of the darker image is below 0.80, and where "a pair of opposing changes" is an increase followed by a decrease, or a decrease followed by an increase;
- A **red flash** is defined as any pair of opposing transitions involving a saturated red.
These standards are based on earlier research. In 2004, The Epilepsy Foundation of America convened a workshop developed a [consensus](https://pubmed.ncbi.nlm.nih.gov/16146438/) on photosensitive seizures, stating _"A flash is a potential hazard if it has luminance at least 20 cd/m<sup>2</sup>, occurs at a frequency of least 3 Hz, and occupies a solid visual angle of at least 0.006 steradians (about 10% of the central visual field or 25% of screen area at typical viewing distances)."_ The transition to or from a saturated red is important and constitutes a risk on its own: "_Irrespective of luminance, a transition to or from a saturated red is also considered a risk._"
### Size and distance
#### How big? It depends
"Relative" size and distance both matter. According to [PEAT](https://trace.umd.edu/peat/), _"The combined area of flashes occurring concurrently occupies no more than a total of one quarter of any 341 x 256 pixel rectangle anywhere on the displayed screen area when the content is viewed at 1024 by 768 pixels."_
The point that the field of vision is an important consideration arises in the article addressing WCAG 2.3.1 continues: "_The 1024 x 768 screen is used as the reference screen resolution for the evaluation. The 341 x 256 pixel block represents a 10 degree viewport at a typical viewing distance. (The 10 degree field is taken from the original specifications and represents the central vision portion of the eye, where people are most susceptible to photo stimuli.)_"
This pixel area ratio calculates for relative size, but distance also matters.
Distance matters because it affects the total field of vision. When viewers wear ocular masks for gaming, the field of vision is likely enveloped in its entirety by the screen. [WebXR](/en-US/docs/Web/API/WebXR_Device_API) is an open specification that makes it possible to experience VR in your browser, which can be experienced on phone, computer or headset. The concern about flashing images in an ocular mask is a growing one, since the mask is so close to the eyes.
Research generally indicates that VR usage may actually be safer than normal screen consumption, due to higher refresh rates. As [Fisher et al. 2022](https://onlinelibrary.wiley.com/doi/full/10.1111/epi.17175) summarizes, _"The limited data so far available raise no special seizure concerns in terms of VR technology, although this view may change with more experience. Certain types of VR content, including bright flashes, provocative patterns, or color changes would be expected to provoke seizures, just as they do in the real world."_
(Note that some users will not be able to see with blinking cursors, and may get migraines, motion sickness, and disorientation, although blinking cursors occupy a much smaller area of the screen.)
### Patterns, and parallax
Contrasting dark and light geometric patterns are a known culprit; stripes and checks are the best known examples. The Epilepsy Foundation of America Working Group lists how many light-dark pairs of stripes are likely to provoke seizures, and, in what conditions. If a pattern is unchanging and straight, eight lines is the maximum allowable, but if it undulates, no more than five lines.
Parallax effects can cause disorientation. Use parallax effects with caution; if you must use them, ensure the user has a control to turn them off.
"A pattern with the potential for provoking seizures contains clearly discernible stripes, numbering more than five light-dark pairs of stripes in any orientation. When the light-dark stripes of any pattern collectively subtend at the eye from the minimal-expected viewing distance a solid angle of >0.006 steradians, the luminance of the lightest stripe is >50 cd/m<sup>2</sup>, and the pattern is presented for ≥0.5 s, then the pattern should display no more than five light-dark pairs of stripes, if the stripes change direction, oscillate, flash, or reverse in contrast; if the pattern is unchanging or smoothly drifting in one direction, no more than eight stripes."
Not all is known, and even with the metrics listed above, additional factors come into play. For example, going from a smaller area to a larger one increases the likelihood that the brain responds, as well as increasing contrast, and increasing spatial frequency from a low to middle. It's also known, although the reasoning is not understood behind it, that going from basic orientations (for example, stripes) to a multiple one (for example, the checkered pattern that emerges when laying one set of stripes on top of, but perpendicular to, the original set) affects the brain.
### Colors
Understanding color is important for accessibility. See [understanding colors and luminance](/en-US/docs/Web/Accessibility/Guides/Colors_and_Luminance) as it relates to web accessibility and accessibility in general.
How the color relates to its background—usually framed in terms of contrast—and how drastically the color changes frame to frame in animation is important. For more on this, see [Three Flashes or Below Threshold Understanding SC 2.3.1](https://www.w3.org/TR/UNDERSTANDING-WCAG20/seizure-does-not-violate.html).
#### The Special Case of Red
It has been demonstrated that [some colors are more likely to cause epileptic fits than others](https://www.sciencedaily.com/releases/2009/09/090925092858.htm). Human physiology and psychology are affected by the color red in general. Its power to influence behavior has even been noted in animals.
- **Red Desaturation tests:** The human eye is so sensitively tuned to red that ophthalmologists set up a test using it. The Red desaturation test assesses the integrity of the optic nerve. For more information as to how an ophthalmologist uses this test, see [Red Desaturation](https://www.smartoptometry.app/red-desaturation/).
- **Red Environment:** Studies have shown that for those who suffer Traumatic Brain Injury, [cognitive function is reduced in a red environment](https://pubmed.ncbi.nlm.nih.gov/20649469/).
[Saturated Red](/en-US/docs/Web/Accessibility/Guides/Colors_and_Luminance) is a special, dangerous case, and there are special tests for it. In addition to a red environment affecting the cognitive function of those with Traumatic Brain Injury, color in the red spectrum wavelength seems to require special concern and special tests. Dr. Gregg Vanderheiden, when testing the Photosensitive Epilepsy Analysis Tool, noted that the seizure rates were much higher than expected. They found that we are much more sensitive to saturated red flashing. (See the video, [The Photosensitive Epilepsy Analysis Tool](https://www.pbs.org/video/university-place-the-photosensitive-epilepsy-analysis-tool-ep-429/).)
#### Websafe does not mean seizure-safe
Note that the color **#990000** is considered "**websafe**". That does _not_ mean it is "safe for not causing seizures", it only means that the color may be "safely" reproduced accurately by the technology used to generate color on screens.
## Measuring to prevent harm
Measuring the potential for harm is a good starting point. Factors considered within tests include color, luminosity, size, contrast, and in cases of animation, frequency. WCAG 2.1 provides guidance for evaluating content.
In August, 2004, the Epilepsy Foundation of America convened a workshop to begin to develop an expert consensus on photosensitive seizures. The following, expert, and authoritative information is from: [Photic- and pattern-induced seizures: expert consensus of the Epilepsy Foundation of America Working Group.](https://pubmed.ncbi.nlm.nih.gov/16146438/)
> A flash is a potential hazard if it has luminance ≥20 cd/m<sup>2</sup>, occurs at a frequency of ≥3 Hz, and occupies a solid visual angle of ≥0.006 steradians (approximately 10% of the central visual field or 25% of screen area at typical viewing distances). A transition to or from saturated red also is considered a risk. A pattern with the potential for provoking seizures contains clearly discernible stripes, numbering more than five light-dark pairs of stripes in any orientation. When the light-dark stripes of any pattern collectively subtend at the eye from the minimal-expected viewing distance a solid angle of >0.006 steradians, the luminance of the lightest stripe is >50 cd/m2, and the pattern is presented for ≥0.5 s, then the pattern should display no more than five light-dark pairs of stripes, if the stripes change direction, oscillate, flash, or reverse in contrast; if the pattern is unchanging or smoothly drifting in one direction, no more than eight stripes. These principles are easier to apply in the case of fixed media, for example, a prerecorded TV show, which can be analyzed frame-by-frame, as compared with interactive media.
The "cd/m<sup>2</sup>" refers to candela per square meter. So for the web developer, how does this relate to measurements for color, luminance, and saturation?
The candela is a SI unit (International System of units) of luminous intensity. It's a photometric term, and photometry deals with the measurement of visible light as perceived by human eyes. Wikipedia's article on ["Candela per square metre"](https://en.wikipedia.org/wiki/Candela_per_square_metre) puts it in terms of what we are familiar with as developers: on a display device, and in the RGB space. This is helpful, because there's a specific standard assumed to be used on monitors, printers, and the Internet, and it is the **sRGB** (standard Red Green Blue).
> As a measure of light emitted per unit area, this unit is frequently used to specify the brightness of a display device. The [sRGB](https://en.wikipedia.org/wiki/SRGB) spec for monitors targets 80 cd/m<sup>2</sup>. Typically, calibrated monitors should have a brightness of 120 cd/m<sup>2</sup>. Most consumer desktop [liquid crystal displays](https://en.wikipedia.org/wiki/Liquid_crystal_display) have luminances of 200 to 300 cd/m<sup>2</sup>. [High-definition televisions](https://en.wikipedia.org/wiki/High-definition_television) range from 450 to about 1500 cd/m<sup>2</sup>.
The takeaway is that the **sRGB** color space is a common touch point between research, assessment tools, and developers, since it is easily converted from the commonly used Hex code.
### Human physiology and psychology as a consideration
Many experts work to quantify and measure to the greatest extent possible the kinds of web content that can serve as triggers for seizures. That said, it can't be forgotten that color is as much about human perception in the brain as it is the measurement of light coming from a computer screen.
In addition to the psychological variances, there are also physiological differences among us. There will be variances and nuances as to how a real human being perceives, and responds to, color and light. For example, Tom Jewett, Lecturer Emeritus of Computer Sciences at Cal State University Long Beach, notes the following concerning [lightness in the HSL color scale](https://colortutorial.design/hsb.html) _"…The distinction between levels of lightness is not actually linear as the HSL scale would imply; we are much more sensitive to changes in lighter values than to darker ones."_
It's important to understand that light and its measurements are linear, but human vision and human perception are not. Investigation and discussion is ongoing as to how to relate the machine measurement of light as it passes from a computer screen, through the distance to the human eye, filtered by human vision, and then manipulated through the human brain.
Even age and sex can play a role. According to the Epilepsy Foundation's article, ["Shedding Light on Photosensitivity, One of Epilepsy's Most Complex Conditions"](https://www.epilepsy.com/stories/shedding-light-photosensitivity-one-epilepsys-most-complex-conditions), _"Children and adolescents are more prone than adults to have an abnormal response to light stimulation, and the first light-induced seizure almost always occurs before age 20"._ The article follows with this statistic: _"Girls (60 percent) are more often affected than boys (40 percent), although seizures are more frequent in boys because they are more likely to be playing video games. Video games often contain potentially provocative light stimulation"_.
**User testing is very problematic**. Naturally, no one wants to subject a seizure-prone individual to user testing. It's dangerous. To that point, one of the most ethical thing that developers and designers can do is use tools that have been developed by experts in the field who have worked hand-in-hand with physicians to develop the tool. As of this writing, there are two commonly available tools that have been ethically and professionally developed by researchers and physicians for film/videos: **PEAT**, and the **Harding Test**.
### Photosensitive Epilepsy Analysis Tool (PEAT)
The [Trace Research and Development Center](https://trace.umd.edu/) has set a gold standard for a [Photosensitive Epilepsy Analysis Tool](https://trace.umd.edu/peat/), and they've made a point to make it **_free_** to download. PEAT can help authors determine whether animations or video in their content are likely to cause seizures. Please note the restriction on its use: **_Use of PEAT to assess material commercially produced for television broadcast, film, home entertainment, or gaming industries is prohibited. Use the Harding Test or other tools for commercial purposes._**
To get a free copy of the University of Maryland's Photosensitive Epilepsy Analysis Tool, visit the [Trace Research & Development Center](https://trace.umd.edu/).

### The Harding Test
As use of the PEAT tool is prohibited for commercial use, television programmers can use the Harding Test at [HardingTest.com](https://hardingtest.com/). The Harding Test is another gold standard. Television programmers in various countries must pass this test before being able to broadcast, so the group at [HardingTest.com](https://hardingtest.com/) provides both analysis and certification of video content.

## Accessibility Solutions for Developers
All animations are potentially dangerous. As designers and developers our responsibility is to ensure we do no harm either intentionally or unintentionally. If we must include something that has the potential to cause harm, it is vital to prevent users from accidentally encountering the harmful content, and to provide ways for users to prevent and control animations mitigating potential harm.
### What the web developer can do
#### Do no harm
[WCAG Guideline 2.3 Seizures and Physical Reactions](https://www.w3.org/WAI/standards-guidelines/wcag/new-in-21/) provides an overview: _"Do not design content in a way that is known to cause seizures or physical reactions"_. Don't include animation that a user cannot control. Don't design with patterns known to cause problems. If you must include a gif or png with flashing in it, record it in a video format instead so that controls are available to the user. Give the user the ability to avoid it, turn it off, or render it less harmful.
#### Understand malice
As a developer or designer, ask yourself if strobing content really needs to be on your webpage. Even if handled properly, there are those who may download offending content from your site and weaponize it. It is believed the first documented attempt at using computers to effect physical harm via animation began Saturday, March 22, 2008: The Epilepsy Foundation's website was hacked via posts with flashing images and links falsely claiming to be helpful. Users with vestibular disorders who were seeking help from the site were affected.
A series of legal considerations are underway after journalist Kurt Eichenwald, a known epileptic, suffered a seizure after being sent an animated gif in December 2016: the flashing gif carried the message, _"You deserve a seizure for your posts"_.
#### Control exposure, control access
Controlling exposure to the page is key to ensuring that someone susceptible to seizures is not exposed to it accidentally. WCAG notes that a single object can make the entire page unusable.
If you believe you may have an image or animation that may cause seizures, control access to it by first displaying a warning about the content, and then putting it in a location where the user must opt in to it, such as clicking a button, or ensuring that the link to the page has a distinct and obvious warning.
Consider setting crawl directives for search engines to hint that they shouldn't include potentially harmful resources in their search indexes.
You can do this using metadata in a [`<meta name="robots">`](/en-US/docs/Web/HTML/Reference/Elements/meta/name/robots) element with restrictive rules like `noindex, nofollow`.
By not indexing the page (`noindex`) and not following links on the page (`nofollow`), the likelihood that users will stumble upon it via search will be reduced:
```html
<html lang="en">
<head>
<title>…</title>
<meta name="robots" content="noindex, nofollow" />
</head>
<body>
…
</body>
</html>
```
For non-HTML resources, you can set crawl directives in a {{httpheader("X-Robots-Tag")}} HTTP response header:
```http
X-Robots-Tag: noindex
```
### Animated GIFs
All image types are potentially dangerous, however, animated GIFs deserve special mention because of their ubiquity, and the fact that the animation speed is actually controlled within the GIF file itself.
#### Detect if a GIF is animated
- The [animated-gif-detector](https://www.npmjs.com/package/animated-gif-detector) npm package allows for the ability to determine animate _as early as possible_ in a given HTTP request.
- Zakirt provides a gist for [animated-gif-detect.js](https://gist.github.com/zakirt/faa4a58cec5a7505b10e3686a226f285)
With animated GIFs, ensure animation is inactive until the user chooses to activate it. For example, the user must push a button or check a box in order to start the animation.
### Videos
As in the case of animated GIFs, the user must push a button or check a box in order to start the animation. There are many ways to do this, such as NOT adding the [`autoplay`](/en-US/docs/Web/API/HTMLMediaElement/autoplay) attribute to `<video controls>`, or setting {{CSSxRef('animation-play-state')}} to `paused` as an initial state. To see a powerful example of how this can actually work see the article by Kirupa, ["Toggling Animations On and Off"](https://www.kirupa.com/html5/toggling_animations_on_off.htm). Kirupa uses the `animation-play-state` in concert with {{CSSxRef('transition')}}, {{CSSxRef('transform')}}, and [`prefers-reduced-motion`](/en-US/docs/Web/CSS/Reference/At-rules/@media/prefers-reduced-motion) to create a very accessible experience under the user's control.
{{cssxref("animation-play-state")}} is a CSS property that sets whether an animation is running or paused.
```css
div {
animation-play-state: paused;
}
```
[CSS transitions](/en-US/docs/Web/CSS/Guides/Transitions) can be used to set the duration to zero for the initial stage of animation.
```css
div {
transition-duration: 0s;
}
```
### Ensure the user can also stop animations as well as start them
A {{HTMLElement('video')}} element with no attributes will not play automatically, and will also have no controls. Ensure that you add the `controls` attribute to the video element so that the user can stop the video as well as start it.
```html
<video controls>
<source src="video.mp4" type="video/mp4" />
<source src="video.ogg" type="video/ogg" />
Your browser does not support the video tag.
</video>
```
#### Programmatically ensure controls are available
The `HTMLMediaElement.controls` property reflects the `controls` HTML attribute, which controls whether user interface controls for playing the media item will be displayed.
##### Video
To ensure that a video has controls that a user can access, ensure that you add the word "controls" to HTML video and audio elements.
`<video controls>`
```html
<video controls>
<source src="myVideo.mp4" type="video/mp4" />
<source src="myVideo.webm" type="video/webm" />
<p>
Your browser doesn't support HTML video. Here is a
<a href="myVideo.mp4">link to the video</a> instead.
</p>
</video>
```
##### Audio
Taking that same example and applying it to audio:
`<audio controls>`
```html
<audio controls>
<source src="myAudio.ogg" type="audio/ogg" />
<source src="myAudio.mp3" type="audio/mpeg" />
<p>
Your browser does not support the audio element. Here is a
<a href="myAudio.mp3">link to the audio</a> instead.
</p>
</audio>
```
##### Audio as part of Video
Note that the audio in videos can be controlled by the `muted` content attribute, even though the content is within the {{HTMLElement('video')}} element rather than the {{HTMLElement('audio')}} element. This example is from the section on [muted media attribute](https://html.spec.whatwg.org/multipage/media.html#concept-media-muted) description from the HTML Living Standard. It explains that the video will autoplay quietly in the background until the user takes action to unmute the audio.
```html
<video src="adverts.cgi?kind=video" controls autoplay loop muted></video>
```
### Control speed
This seems obvious, but because there are so many MIME types, the mechanisms for handling them varies greatly, and for that reason there's not a one-size-fits-all solution to the problem. This is further complicated by the fact that even how files are classified complicates how they should be handled. For example, the .gif file format is usually understood to be an image, but is also considered a video file format in some circles because of its ability to be animated. For a comprehensive listing of media types, please visit [IANA.org's page for Media Types](https://www.iana.org/assignments/media-types/media-types.xhtml).
The methods for sniffing them out is not a casual exercise. You may be interested in following the [MIME Sniffing](https://mimesniff.spec.whatwg.org/) standard at whatwg.org. Just about every kind of image can be animated; how they are animated varies, and therefore, the control of the animation varies.
#### Commonly animated file types
- **Bitmap**: Animation
- **Canvas**: MDN's tutorial on Canvas has a great section on [basic animations](/en-US/docs/Web/API/Canvas_API/Tutorial/Basic_animations). `setInterval()` is a mainstay in Canvas animation, but it is also interesting to see how it interacts with screen refresh. See the article, ["Controlling fps with requestAnimationFrame?"](https://stackoverflow.com/questions/19764018/controlling-fps-with-requestanimationframe) in which they discuss the nuts and bolts of implementing `requestAnimationFrame` against the backdrop of screen refresh.
- **GIFs (Raster)**: Tough to crack because control for their animation resides within the gif files themselves. For information about controlling the speed of GIFs see W3C's ["G152: Setting animated gif images to stop blinking after n cycles (within 5 seconds)"](https://www.w3.org/TR/WCAG20-TECHS/G152.html). A great Stack Overflow article on the subject is, ["Can you control GIF animation with JavaScript?"](https://stackoverflow.com/questions/2385203/can-you-control-gif-animation-with-javascript)
- **GIFV (Raster)**: Considered a variant, video version of GIF. The format is not standardized, and must reference a "real" video file (e.g., a .webm file) which must exist elsewhere.
- **JPG (Raster)**
- **MNG (Raster)**: Multiple-image Network Graphics is a graphics file format for animated images. Also considered by some to be a video format.
- **PNG, APNG (Raster)**: Portable Network Graphics and Animated Portable Network Graphics may both be animated.
- **SVGs (Vector)**: The MDN document, ["SVG: Scalable Vector Graphics"](/en-US/docs/Web/SVG), notes that _"SVG is a text-based open Web standard. It is explicitly designed to work with other web standards such as [CSS](/en-US/docs/Web/CSS), [DOM](/en-US/docs/Web/API/Document_Object_Model), and [SMIL](/en-US/docs/Web/SVG/Guides/SVG_animation_with_SMIL)."_ SVGs can be used as an image like in this example: `<img src="example.svg" alt="This is an image using a svg as a source">`. This means that SVG appearance and animation can be controlled through CSS keyframes and animations. For interaction with JavaScript, see the MDN documents on [SVG Interfaces](/en-US/docs/Web/API/Document_Object_Model#svg_dom) and [Applying SVG effects to HTML content](/en-US/docs/Web/SVG/Guides/Applying_SVG_effects_to_HTML_content).
- **Voxel (Raster)**: Three-dimensional [voxel](https://en.wikipedia.org/wiki/Voxel) raster graphics are employed in video games, as well as in medical imaging.
#### Text can also be animated
Translations and transformations can animate text in a div, and do harm. Moving text can induce seizures for the same reasons that moving images do, so avoid animating your text. It's a good idea to avoid using moving text anyhow, as many screen readers cannot read moving text and it's bad user experience even for those with no vision or vestibular issues.
### CSS for animation
In the style sheet or within the {{HTMLElement('style')}} element, many options can combine together to create a powerful experience for the user. We've already mentioned the `animation` property earlier in this document. It's actually shorthand for all animation properties, including:
- `animation-play-state`
- `animation-duration` has a value of `<time>`; this is the duration an animation takes to complete one cycle. This may be specified in either seconds `(s)` or milliseconds `(ms)`. A default value of `0s` indicates no animation should occur.
- `animation-timing-function`
The animation property is already powerful on its own, but combined with other properties and queries such as `prefers-reduced-motion`, a powerful set of options can be set up for the user. Setting `animation-duration` and `transition-duration` properties to a short duration rather than setting them to `animation: none` and `transition: none`, enables a safeguard to prevent issues in any case there is a dependency on the animation to run.
### JavaScript animation
JavaScript is often used to control {{HTMLElement('canvas')}} elements and SVGs. Most JavaScript code that applies to HTML video also applies to audio. `HTMLMediaElement.playbackRate` is used to implement user controls for the playback rate for both video and audio. A value of 1.0 is default and considered normal speed; a value of 0.5 is half the speed, a value of 2.0 is twice the speed. A negative number plays the video or audio backwards. Set the playback rate property: `HTMLMediaElement.playbackRate = playbackSpeed`.
[document.getAnimations()](/en-US/docs/Web/API/Document/getAnimations) is an experimental technology, and includes [CSS Animations](/en-US/docs/Web/CSS/Guides/Animations), [CSS Transitions](/en-US/docs/Web/CSS/Guides/Transitions), and [Web Animations](/en-US/docs/Web/API/Web_Animations_API). The MDN page on [Document.getAnimations()](/en-US/docs/Web/API/Document/getAnimations) provides the following code sample of how to slow down all animations on a page to half speed:
```js
document.getAnimations().forEach((animation) => {
animation.playbackRate *= 0.5;
});
```
#### Image sources for animation
One of the easiest ways is to start with an image that is already in existence, using it as an image source, and then animating it. Remember, you can use GIFs, JPGs, PNGs, SVGs and other file types here as an image source, as long as they are allowed file types—and sizes—in your environment. SVGs are often not allowed, due to security concerns. The MDN document, [Basic animations](/en-US/docs/Web/API/Canvas_API/Tutorial/Basic_animations), provides outstanding examples of this, using multiple image sources for the sun, earth, and moon, and using several canvas methods to control the speed and animation of the earth as it orbits around the sun, and the moon as it orbits around the earth. Use the codepen available with this tutorial to adjust `ctx.rotate` in the code to see how the animation is affected when changes are made.
#### If you absolutely, positively must use a flashing animation…
Make sure it has a control on it. Make sure it is turned off when the viewer first encounters it, and that a user must opt-in to see the animation.
An example of a format that has no controls available to the user is a gif file. Animation speed is controlled within the gif image itself. Converting an animated gif to video enables controls to be put on the animation, and gives the user agency. There are many free online converters available for use, such as [EZGif](https://ezgif.com/) and [GIF to MP4](https://gif-2-mp4.com/).
#### Set user expectations
Give users a heads-up as to what will happen before they click on that link. Describe the animation that is to follow. See [WCAG 2.2 Success Criterion 3.2.5 Change on Request](https://w3c.github.io/wcag/guidelines/22/#change-on-request).
#### Keep it small
If you absolutely positively must have flashing, keep it small. Generally speaking, limit the size of the flash to an area approximately 341 by 256 pixels or less. This pixel size assumes that a viewer is at a typical distance from the screen. As mentioned earlier, this size may be too big if the image is to be viewed at close range, such as in a VR headset. WebVR is an open specification that makes it possible to experience VR in your browser. WebVR can be experienced on phone, computer or headset.
If you are designing for a game or VR that uses an ocular mask, **or CAN be used by an ocular mask**, such as in Firefox Reality (a browser for virtual reality), ensure that the size of the rectangle is much smaller than 341 by 256 pixels, because the image is much closer to a user's eyes.
#### Reduce contrast
Normally, higher contrast is a good thing when it comes to accessibility. The greater the contrast of a text color to its background (technically called _luminosity contrast ratio,_ according to W3.org's page on [Colors with Good Contrast](https://www.w3.org/WAI/perspective-videos/contrast/), the easier such content is to read. Users with low vision are especially appreciative of efforts to ensure high contrast of text against its background. When the content is animated, however, **_reducing_** contrast is actually a way to reduce the likelihood that the animated content will cause seizures. Drop the contrast ratio if three flashes within one second are detected.
The contrast ratio is defined in [WCAG 2.2](https://w3c.github.io/wcag/guidelines/22/) as follows:
- _contrast ratio_
- : (L1 + 0.05) / (L2 + 0.05), where
- L1 is the [relative luminance](https://w3c.github.io/wcag/guidelines/22/#dfn-relative-luminance) of the lighter of the colors, and
- L2 is the [relative luminance](https://w3c.github.io/wcag/guidelines/22/#dfn-relative-luminance) of the darker of the colors.
It's best if you can adjust the contrast before it is uploaded or published to the web. For videos and animated GIFs, the Adobe Suite of products is a phenomenal resource for traditional images. Also for images, an online tool available is pinetools.com's [Brightness and contrast online](https://pinetools.com/brightness-contrast-image). If you intend to make animated GIFs, for example, start with one that has a lower contrast ratio.
JavaScript is also an option for reducing contrast dynamically. Here's a code example from the section titled, ["Example: Setting the background color of a paragraph"](/en-US/docs/Web/API/Document_Object_Model/Building_and_updating_the_DOM_tree#setting_the_background_color_of_a_paragraph). Notice that the color in the example is described in the **RGB** color space.
**HTML Content [(link to source page)](/en-US/docs/Web/API/Document_Object_Model/Building_and_updating_the_DOM_tree#html_2)**
```html
<body>
<input type="button" value="Set paragraph background color" />
<p>hi</p>
<p>hello</p>
</body>
```
**JavaScript Content [(link to source page)](/en-US/docs/Web/API/Document_Object_Model/Building_and_updating_the_DOM_tree#javascript_2)**
```js
function setBackground() {
// now, get all the p elements in the document
const paragraphs = document.getElementsByTagName("p");
// get the second paragraph from the list
const secondParagraph = paragraphs[1];
// set the inline style
secondParagraph.style.background = "red";
}
document.querySelector("input").addEventListener("click", setBackground);
```
#### Avoid fully saturated reds for flashing content
As mentioned earlier in this document, the Epilepsy Foundation of America convened a workshop in August 2004 to begin to develop an expert consensus on photosensitive seizures. Among their results was the understanding that _"A flash is a potential hazard if it has luminance at least 20 cd/m2, occurs at a frequency of least 3 Hz, and occupies a solid visual angle of at least 0.006 steradians (about 10% of the central visual field or 25% of screen area at typical viewing distances). A transition to or from saturated red also is considered a risk."_ They also note in that same consensus: _"Irrespective of luminance, a transition to or from a saturated red is also considered a risk."_
### Provide alternative CSS styles
With the understanding that much of animation and flashing can be controlled via CSS methods, it's important to explore ways to make alternative options available to users, and to make the control of these options convenient and visible.
#### Alternative Style Sheets
Modern browsers will display the alternate CSS available in alternate style sheets if the users know where to look for them. In some cases, the alternate styles are revealed when the users go through the View menu, in other cases they are manifested in the settings, sometimes both. Not all users know to look for these options via the browser or settings, so it's worth considering doing things the old-fashioned way, with obvious buttons or links to change the style so that users can see them. Doing so won't conflict with, or override, the browser's ability to read the alternate style sheets, or the ability of the user to set preferences in the settings.
It's important to know that certain users, such as those who rely on speech-recognition systems, often depend on legacy buttons and links because their disability prevents them from using a mouse, or to be able to take advantage of touch events on mobile tablets.
Common ways to include the alternative stylesheets into your HTML documents are to use the {{HTMLElement('link')}} element, and {{CSSxref('@import')}}.
#### The {{HTMLElement('link')}} element
Use the {{HTMLElement('link')}} element, alongside with and together with the attributes of `rel="alternate stylesheet"` and for title, `title="…"` in the {{HTMLElement('head')}} section of the webpage.
```html
<head>
<title>Home Page</title>
<link href="main.css" rel="stylesheet" title="Default Style" />
<link
href="alternate1.css"
rel="alternate stylesheet"
title="Alternate One" />
<link
href="alternate2.css"
rel="alternate stylesheet"
title="Alternate Two" />
</head>
```
**{{CSSxref('@import')}}** is also a way to incorporate style sheets, but it is not quite as well supported as the {{HTMLElement('link')}} element.
```css
@import "alternate1.css";
@import "alternate2.css";
```
By using alternate style sheets (remember to add the titles) you are setting it up for users to be able to use their browsers to choose alternate styles.
### Dynamic Style Switching
One problem with relying on the browser to reveal alternative styles is that not all users are technically savvy enough to discover the alternate styles. Or, because of their disability, are not able to. Buttons or links make it obvious that options are available to many grateful users. There's a multitude of ways to add toggle buttons to allow the user to switch to the different style sheets. That said, the use of alternative style sheets are not the only option. Another option is to manipulate the style of the page itself. According to the MDN document, [Using dynamic styling information](/en-US/docs/Web/API/CSS_Object_Model/Using_dynamic_styling_information), _"where possible, it really is best practice to dynamically manipulate classes via the [`className`](/en-US/docs/Web/API/Element/className) property since the ultimate appearance of all of the styling hooks can be controlled in a single stylesheet"._ One of the best examples around as to how to do this is from the W3C's page, ["C29: Using a style switcher to provide a conforming alternate version"](https://www.w3.org/TR/WCAG20-TECHS/C29.html).
### Extreme Cases: Text-Only Alternatives
A separate, alternative stylesheet that prevents images from being displayed is easy to make. It's a draconian solution; but it is one that is sometimes necessary for school teachers and other public servants who must serve those with extreme sensitivities. These public servants can ask their developers to develop a special alternative style sheet using `display: none`. Here's how to do it via CSS:
```css
img {
display: none;
}
```
#### Take advantage of media queries with {{HTMLElement('style')}}
In setting up media queries, you are enabling controls by the user; these controls are made available in the browser or in the OS. See the MDN document, [Accessibility: What users can do to browse more safely](/en-US/docs/Web/Accessibility/Guides/Browsing_safely) to see more details of how a user accesses the controls.
#### `prefers-reduced-motion`
Support for `prefers-reduced-motion` in modern browsers is growing.
```css
@media screen and (prefers-reduced-motion: reduce) {
}
@media screen and (prefers-reduced-motion) {
}
```
To see a great example of how to use the code `prefers-reduced-motion`, visit the MDN document, [`prefers-reduced-motion`](/en-US/docs/Web/CSS/Reference/At-rules/@media/prefers-reduced-motion), or see the example below from the section on ["New in Chrome 74"](https://developer.chrome.com/blog/new-in-chrome-74/).
```css
button {
animation: vibrate 0.3s linear infinite both;
}
@media (prefers-reduced-motion: reduce) {
button {
animation: none;
}
}
```
#### `prefers-color-scheme`
This can be useful if the ambient light API is not available. Support is emerging.
```css
@media (prefers-color-scheme: dark) {
/* adjust styles for dark mode */
}
```
#### Window.matchMedia()
There is a powerful tool available to developers via Window.matchMedia(). A great resource is MDN's document on [`Window.matchMedia()`](/en-US/docs/Web/API/Window/matchMedia).
#### Media update feature
The more often the screen is refreshed, the more stable it appears to the human eye, and the less it "flickers". The vast majority of modern technology refreshes at a rate that does not cause problems with photosensitivity. However, not everybody is wealthy enough to be able to afford the most recent technology: older or underpowered computers can have low refresh rates. [AbilityNet's Factsheet (November 2015) Computers and Epilepsy](https://www.abilitynet.org.uk/sites/abilitynet.org.uk/files/Epilepsy%20and%20Computing%20Nov%202015.pdf) describes more of the details on refresh rates.
A very old article, Tech Republic's ["Epilepsy and CRT/LCD screen flicker"](https://www.techrepublic.com/forums/discussions/epilepsy-and-crt-lcd-screen-flicker/), had an interesting response concerning the refresh rates in Hz:
- _"This effect is noticeable, and documented, up to 70 Hz."_
- _"These studies would seem to indicate that you should stay away from refresh rates under 70 Hz, and use a rate not divisible by 10."_
Eric Bailey, of CSS-Tricks, found an innovative use the update feature which, used in combination with animation-duration or transition-duration, to conclude at a rate that is imperceptible to the human eye. In other words, Eric's techniques address the refresh-rate problem. The CSS below is from the CSS-Tricks article, [" Revisiting prefers-reduced-motion, the reduced motion media query"](https://css-tricks.com/revisiting-prefers-reduced-motion/).
```css
@media screen and (prefers-reduced-motion: reduce), (update: slow) {
* {
animation-duration: 0.001ms !important;
animation-iteration-count: 1 !important; /* Hat tip Nick/cssremedy (https://css-tricks.com/revisiting-prefers-reduced-motion/#comment-1700170) */
transition-duration: 0.001ms !important;
}
}
```
The [`update`](/en-US/docs/Web/CSS/Reference/At-rules/@media/update) media feature is used to query the ability of the output device to modify the appearance of content once it has been rendered. It has the values of "none", "slow", and "fast".
## Developmental & Experimental Features
### Media Queries Level 5
EnvironmentMQ (Planned in Media Queries Level 5)
- `light-level`
- : [`light-level`](https://drafts.csswg.org/mediaqueries-5/#light-level) has three valid values: dim, normal, and washed. Interestingly, the specification refrains from actually defining the three levels in terms of a measurement of lux, because devices with a light sensor usually adjust the brightness of the screen automatically. The specifications also note the difference in technology, such as e-ink, which remains readable in bright daylight, versus liquid crystals, which do not.
- `environment-blending`
- : From W3C's Draft document, Media Queries Level 5: _"The [`environment-blending`](https://drafts.csswg.org/mediaqueries-5/#descdef-media-environment-blending) media feature is used to query the characteristics of the user's display so the author can adjust the style of the document. An author might choose to adjust the visuals and/or layout of the page depending on the display technology to increase the appeal or improve legibility."_
#### User Preference Media Features (Planned in Media Queries Level 5)
[User Preference Media Features](https://drafts.csswg.org/mediaqueries-5/#mf-user-preferences) in [W3C Editor's Draft Media Queries Level 5](https://drafts.csswg.org/mediaqueries-5/) are especially promising in providing user control over media. Here are some highlights:
- `inverted-colors`
- : According to the section, [User Preference Media Features](https://drafts.csswg.org/mediaqueries-5/#mf-user-preferences), "The [`inverted-colors`](https://drafts.csswg.org/mediaqueries-5/#descdef-media-inverted-colors) media feature indicates whether the content is displayed normally, or whether colors have been inverted."
- [`forced-colors`](/en-US/docs/Web/CSS/Reference/At-rules/@media/forced-colors)
- : In [`forced-colors-mode`](https://drafts.csswg.org/css-color-adjust-1/#forced-colors-mode), the user agent enforces the user's preferred color palette on the page, overriding the author's chosen colors. From W3C's Draft document, Media Queries Level 5 section on forced-colors: _"The forced-colors media feature is used to detect if the user agent has enabled a [forced colors mode](https://drafts.csswg.org/css-color-adjust-1/#forced-colors-mode) where it enforces a user-chosen limited color palette on the page"._ The user will need to be made aware of this ability, and it will need to play nice with the appropriate value for the prefers-color-scheme media query.
- `light-level`
- : From W3C's Draft document, Media Queries Level 5 section on light-level: _"The [`light-level`](https://drafts.csswg.org/mediaqueries-5/#descdef-media-light-level) media feature is used to query about the ambient light-level in which the device is used, to allow the author to adjust style of the document in response."_ This will be a godsend to those who have motor-skills problems, or for some with cognitive difficulties, who cannot find the right "button" to change their screen settings.
- prefers-contrast
- : From W3C's Draft document, Media Queries Level 5 section on [`prefers-contrast`](/en-US/docs/Web/CSS/Reference/At-rules/@media/prefers-contrast): _"The `prefers-contrast` media feature is used to detect if the user has requested the system increase or decrease the amount of contrast between adjacent colors. For example, many users have difficulty reading text that has a small difference in contrast to the text background and would prefer a larger contrast."_ Sometimes there can be such a thing as too much contrast; a halo effect around text can occur in such situations and actually reduce legibility. Putting the amount of contrast in the user's control is a definite gift for accessibility.
#### `MediaQueryList` Interface
Section 4.2 from the CSSWG.org drafts integrates with the [event loop](https://html.spec.whatwg.org/multipage/webappapis.html#event-loop) defined in HTML. [HTML](https://drafts.csswg.org/cssom-view/#biblio-html) for the [`MediaQueryList`](https://drafts.csswg.org/cssom-view/#mediaquerylist) object. See the MDN document, [MediaQueryList](/en-US/docs/Web/API/MediaQueryList) for more information.
#### Personalization Help and Support
The requirement for the `literal` property is taken from [WAI-Adapt: Help and Support](https://w3c.github.io/adapt/help/#literal-explanation).
**Requirement:** Some users cannot understand non-literal text and icons such as metaphors, idioms etc. The `literal` property is intended to identify text or images as non-literal and allows the author to explain non-literal text and images to users.
## See also
### MDN
- [Accessibility: What users can do to browse more safely](/en-US/docs/Web/Accessibility/Guides/Browsing_safely)
- [Accessibility: Understanding color and luminance](/en-US/docs/Web/Accessibility/Guides/Colors_and_Luminance)
- [Applying SVG effects to HTML Content](/en-US/docs/Web/SVG/Guides/Applying_SVG_effects_to_HTML_content)
- [Basic Animations](/en-US/docs/Web/API/Canvas_API/Tutorial/Basic_animations) (Canvas Tutorial)
- [Canvas API](/en-US/docs/Web/API/Canvas_API)
- [CanvasRenderingContext2D.drawImage()](/en-US/docs/Web/API/CanvasRenderingContext2D/drawImage)
- {{cssxref("<color>")}}
- [Document Object Model](/en-US/docs/Web/API/Document_Object_Model)
- [MediaQueryList](/en-US/docs/Web/API/MediaQueryList)
- [Using dynamic styling information](/en-US/docs/Web/API/CSS_Object_Model/Using_dynamic_styling_information)
- [WebGL: 2D and 3D graphics for the web](/en-US/docs/Web/API/WebGL_API)
- [WebVR API](/en-US/docs/Web/API/WebVR_API)
### Color
- [Color Tutorial: describing color](https://colortutorial.design/) Tom Jewett
- [Formula to Determine Brightness of RGB color](https://stackoverflow.com/questions/596216/formula-to-determine-perceived-brightness-of-rgb-color) Stack Exchange Discussion Thread
- [How the Color Red Influences Our Behavior](https://www.scientificamerican.com/article/how-the-color-red-influences-our-behavior/) Scientific American By Susana Martinez-Conde, Stephen L. Macknik on November 1, 2014
### Discussions
- [Problems with WCAG 2.0 Flash Definition #553](https://github.com/w3c/wcag/issues/553)
- [WCAG 2.1 Understanding 2.3.1 - missing/vague dimension definitions #585](https://github.com/w3c/wcag/issues/585)
### Epilepsy and Seizures
- [Shedding Light on Photosensitivity, One of Epilepsy's Most Complex Conditions](https://www.epilepsy.com/stories/shedding-light-photosensitivity-one-epilepsys-most-complex-conditions) Epilepsy Foundation: _"Certain individuals are born with special sensitivity to flashing lights or contrasting visual patterns, such as stripes, grids and checkerboards. Because of this condition, their brain will produce seizure-like discharges when exposed to this type of visual stimulation."_
- [Gamma oscillations and photosensitive epilepsy](https://www.sciencedirect.com/science/article/pii/S0960982217304062?via%3Dihub) Current Biology [Volume 27, Issue 9](https://www.sciencedirect.com/journal/current-biology/vol/27/issue/9), 8 May 2017, Pages R336-R338: _"Certain [visual images](https://www.sciencedirect.com/topics/biochemistry-genetics-and-molecular-biology/retina-image), even in the absence of motion or flicker, can trigger seizures in patients with photosensitive epilepsy."_
- [Photosensitive Seizures. Cedars-Sinai](https://www.cedars-sinai.org/health-library/diseases-and-conditions/p/photosensitive-seizures.html) "_Photosensitive seizures are triggered by flashing or flickering lights. These seizures can also be triggered by certain patterns such as stripes._"
- [Photic-and pattern-induced seizures: expert consensus of the Epilepsy Foundation of America Working Group](https://pubmed.ncbi.nlm.nih.gov/16146438/) Eplepsia 2005 Sept, 46(9):1423-5 PubMed.gov NCBI [Harding G](https://pubmed.ncbi.nlm.nih.gov/?term=Harding%20G%5BAuthor%5D&cauthor=true&cauthor_uid=16146438), [Wilkins AJ](https://pubmed.ncbi.nlm.nih.gov/?term=Wilkins%20AJ%5BAuthor%5D&cauthor=true&cauthor_uid=16146438), [Erba G](https://pubmed.ncbi.nlm.nih.gov/?term=Erba%20G%5BAuthor%5D&cauthor=true&cauthor_uid=16146438), [Barkley GL](https://pubmed.ncbi.nlm.nih.gov/?term=Barkley%20GL%5BAuthor%5D&cauthor=true&cauthor_uid=16146438), [Fisher RS](https://pubmed.ncbi.nlm.nih.gov/?term=Fisher%20RS%5BAuthor%5D&cauthor=true&cauthor_uid=16146438); [Epilepsy Foundation of America Working Group](https://pubmed.ncbi.nlm.nih.gov/?term=Epilepsy%20Foundation%20of%20America%20Working%20Group%5BCorporate%20Author%5D).
### GPII
- [Accessibility Master List](https://ds.gpii.net/learn/accessibility-masterlist) Gregg Vanderheiden Ph.D. Editor
### ISO
- [IEC 61966-2-2:2003(en)](https://www.iso.org/obp/ui/#iso:std:iec:61966:-2-2:ed-1:v1:en) Multimedia systems and equipment — Colour measurement and management — Part 2-2: Colour management — Extended RGB color space — scRGB
### Photosensitive Epilepsy Analysis Tool
Along with the Harding tool, is generally recognized to be one of the two "gold standards" for analyzing flashes.
- [Trace Research and Development Center](https://trace.umd.edu/peat/)
- [Using PEAT To Create Seizureless Web Animations](https://www.useragentman.com/blog/2017/04/02/using-peat-to-create-seizureless-web-animations/)
### W3C
- [WAI-Adapt Explainer](https://w3c.github.io/adapt/)
- [WAI-Adapt: Tools Module](https://www.w3.org/TR/adapt-tools/) Working Draft
- [Three Flashes or Below Threshold Understanding SC 2.3.1](https://www.w3.org/TR/UNDERSTANDING-WCAG20/seizure-does-not-violate.html) Understanding WCAG 2.0 (Older, but contains some explanations of references made in the WCAG 2.1 criteria)
- [Three Flashes or Below Threshold Understanding Success Criterion 2.3.1](https://www.w3.org/WAI/WCAG21/Understanding/three-flashes-or-below-threshold.html) Understanding WCAG 2.1
- [Understanding Success Criteria 1.4.3: Contrast (Minimum)](https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum.html)
- [Web Accessibility Initiative (WAI)](https://www.w3.org/WAI/)
- [Web Content Accessibility Guidelines (WCAG) 2.2](https://w3c.github.io/wcag/guidelines/22/#dfn-relative-luminance) definition of relative luminance
|
---
title: An overview of accessible web applications and widgets
short-title: Accessible web applications and widgets
slug: Web/Accessibility/Guides/Accessible_web_applications_and_widgets
page-type: guide
sidebar: accessibilitysidebar
---
Most JavaScript libraries offer a library of client-side widgets that mimic the behavior of familiar desktop interfaces. Sliders, menu bars, file list views, and more can be built with a combination of JavaScript, CSS, and HTML. Since the HTML4 specification doesn't provide built-in tags that semantically describe these kinds of widgets, developers typically resort to using generic elements such as {{HTMLElement('div')}} and {{HTMLElement('span')}}. While this results in a widget that looks like its desktop counterpart, there usually isn't enough semantic information in the markup to be usable by an assistive technology.
## The problem
Dynamic content on a web page can be particularly problematic for users who, for whatever reason, are unable to view the screen. Stock tickers, live twitter feed updates, progress indicators, and similar content modify the DOM in ways that an assistive technology (AT) may not be aware of. That's where [ARIA](/en-US/docs/Web/Accessibility/ARIA) comes in.
_Example 1: Markup for a tabs widget built without ARIA labeling. There's no information in the markup to describe the widget's form and function._
```html
<!-- This is a tabs widget. How would you know, looking only at the markup? -->
<ol>
<li id="ch1Tab">
<a href="#ch1Panel">Chapter 1</a>
</li>
<li id="ch2Tab">
<a href="#ch2Panel">Chapter 2</a>
</li>
<li id="quizTab">
<a href="#quizPanel">Quiz</a>
</li>
</ol>
<div>
<div id="ch1Panel">Chapter 1 content goes here</div>
<div id="ch2Panel">Chapter 2 content goes here</div>
<div id="quizPanel">Quiz content goes here</div>
</div>
```
_Example 2: How the tabs widget might be styled visually. Users might recognize it visually, but there are no machine-readable semantics for an assistive technology._ 
## ARIA
**ARIA** enables developers to describe their widgets in more detail by adding special attributes to the markup. Designed to fill the gap between standard HTML tags and the desktop-style controls found in dynamic web applications, ARIA provides roles and states that describe the behavior of most familiar UI widgets.
> [!WARNING]
> Many of these were later added when browsers didn't fully support modern HTML features. **Developers should always prefer using the correct semantic HTML element over using ARIA**.
The ARIA specification is split up into three different types of attributes: roles, states, and properties. Roles describe widgets that aren't otherwise available in HTML 4, such as sliders, menu bars, tabs, and dialogs. Properties describe characteristics of these widgets, such as if they are draggable, have a required element, or have a popup associated with them. States describe the current interaction state of an element, informing the assistive technology if it is busy, disabled, selected, or hidden.
ARIA attributes are interpreted automatically by the browser and translated to the operating system's native accessibility APIs. So an element with role="slider" will be controlled in the same way as a native slider is controlled on the operating system.
This provides a much more consistent user experience than was possible in the previous generation of web applications, since assistive technology users can apply all of their knowledge of how desktop applications work when they are using web-based applications.
_Example 3: Markup for the tabs widget with ARIA attributes added._
```html
<!-- Now *these* are Tabs! -->
<!-- We've added role attributes to describe the tab list and each tab. -->
<ol role="tablist">
<li id="ch1Tab" role="tab">
<a href="#ch1Panel">Chapter 1</a>
</li>
<li id="ch2Tab" role="tab">
<a href="#ch2Panel">Chapter 2</a>
</li>
<li id="quizTab" role="tab">
<a href="#quizPanel">Quiz</a>
</li>
</ol>
<div>
<!-- Notice the role and aria-labelledby attributes we've added to describe these panels. -->
<div id="ch1Panel" role="tabpanel" aria-labelledby="ch1Tab">
Chapter 1 content goes here
</div>
<div id="ch2Panel" role="tabpanel" aria-labelledby="ch2Tab">
Chapter 2 content goes here
</div>
<div id="quizPanel" role="tabpanel" aria-labelledby="quizTab">
Quiz content goes here
</div>
</div>
```
ARIA is [well supported](https://caniuse.com/#feat=wai-aria) by all major browsers and many assistive technologies.
### Presentational changes
Dynamic presentational changes include using CSS to change the appearance of content (such as a red border around invalid data, or changing the background color of a checked checkbox), as well as showing or hiding content.
#### State changes
ARIA provides attributes for declaring the current state of a UI widget. Examples include (but are certainly not limited to):
- `aria-checked`
- : Indicates the state of a checkbox or radio button.
- `aria-disabled`
- : Indicates that an element is visible but not editable or otherwise operable.
- `aria-grabbed`
- : Indicates the 'grabbed' state of an object in a drag-and-drop operation.
(For a full list of ARIA states, consult the [ARIA list of states and properties](https://w3c.github.io/aria/#introstates).)
Developers should use ARIA states to indicate the state of UI widget elements and use CSS attribute selectors to alter the visual appearance based on the state changes (rather than using script to change a class name on the element).
#### Visibility changes
When content visibility is changed (i.e., an element is hidden or shown), developers should change the **`aria-hidden`** property value. The techniques described above should be used to declare CSS to visually hide an element using `display:none`.
Here is an example of a tooltip that uses **`aria-hidden`** to control the visibility of the tooltip. The example shows a web form with tooltips containing instructions associated with the entry fields.
```html
<div class="text">
<label id="tp1-label" for="first">First Name:</label>
<input
type="text"
id="first"
name="first"
size="20"
aria-labelledby="tp1-label"
aria-describedby="tp1"
aria-required="false" />
<div id="tp1" class="tooltip" role="tooltip" aria-hidden="true">
Your first name is optional
</div>
</div>
```
The CSS for this markup is shown in the following code. Note that there is no custom classname used, only the status of the **`aria-hidden`** attribute.
```css
div.tooltip[aria-hidden="true"] {
display: none;
}
```
The JavaScript to update the **`aria-hidden`** property has the form shown in the following code. Note that the script only updates the **`aria-hidden`** attribute; it does not need to also add or remove a custom classname.
```js
function showTip(el) {
el.setAttribute("aria-hidden", "false");
}
```
### Role changes
ARIA allows developers to declare a semantic role for an element that otherwise offers incorrect or no semantics. The **`role`** of an element should not change. Instead, remove the original element and replace it with an element with the new **`role`**.
For example, consider an "inline edit" widget: a component that allows users to edit a piece of text in place, without switching contexts. This component has a "view" mode, in which the text is not editable, but is activatable, and an "edit" mode, in which the text can be edited. A developer might be tempted to implement the "view" mode using a read-only text {{ HTMLElement("input") }} element and setting its ARIA **`role`** to `button`, then switching to "edit" mode by making the element writable and removing the **`role`** attribute in "edit" mode (since {{ HTMLElement("input") }} elements have their own role semantics).
Do not do this. Instead, implement the "view" mode using a different element altogether, such as a {{ HTMLElement("div") }} or {{ HTMLElement("span") }} with a **`role`** of `button`, and the "edit" mode using a text {{ HTMLElement("input") }} element.
### Asynchronous content changes
> [!NOTE]
> Under construction. See also [Live Regions](/en-US/docs/Web/Accessibility/ARIA/Guides/Live_regions)
## Keyboard navigation
Often times developers overlook support for the keyboard when they create custom widgets. To be accessible to a variety of users, all features of a web application or widget should also be controllable with the keyboard, without requiring a mouse. In practice, this usually involves following the conventions supported by similar widgets on the desktop, taking full advantage of the Tab, Enter, Spacebar, and arrow keys.
Traditionally, keyboard navigation on the web has been limited to the Tab key. A user presses Tab to focus each link, button, or form on the page in a linear order, using Shift-Tab to navigate backwards. It's a one-dimensional form of navigation—forward and back, one element at a time. On fairly dense pages, a keyboard-only user often has to press the Tab key dozens of times before accessing the needed section. Implementing desktop-style keyboard conventions on the web has the potential to significantly speed up navigation for many users.
Here's a summary of how keyboard navigation should work in an ARIA-enabled web application:
- The Tab key should provide focus to the widget as a whole. For example, tabbing to a menu bar **should NOT** put focus on the menu's first element.
- The arrow keys should allow for selection or navigation within the widget. For example, using the left and right arrow keys should move focus to the previous and next menu items.
- When the widget is not inside a form, both the Enter and Spacebar keys should select or activate the control.
- Within a form, the Spacebar key should select or activate the control, while the Enter key should submit the form's default action.
- If in doubt, mimic the standard desktop behavior of the control you are creating.
So, for the Tabs widget example above, the user should be able to navigate into and out of the widget's container (the {{HTMLElement('ol')}} in our markup) using the Tab and Shift-Tab keys. Once keyboard focus is inside the container, the arrow keys should allow the user to navigate between each tab (the {{HTMLElement('li')}} elements). From here, conventions vary from platform to platform. On Windows, the next tab should automatically be activated when the user presses the arrow keys. On macOS, the user can press either Enter or the Spacebar to activate the next tab. An in-depth tutorial for creating [Keyboard-navigable JavaScript widgets](/en-US/docs/Web/Accessibility/Guides/Keyboard-navigable_JavaScript_widgets) describes how to implement this behavior with JavaScript.
## See also
- [ARIA](/en-US/docs/Web/Accessibility/ARIA)
- [Writing Keyboard-navigable JavaScript widgets](/en-US/docs/Web/Accessibility/Guides/Keyboard-navigable_JavaScript_widgets)
- [WAI-ARIA Specification](https://w3c.github.io/aria/)
- [WAI-ARIA Authoring Practices](https://www.w3.org/WAI/ARIA/apg/)
|
---
title: Keyboard-navigable JavaScript widgets
slug: Web/Accessibility/Guides/Keyboard-navigable_JavaScript_widgets
page-type: guide
sidebar: accessibilitysidebar
---
Web applications often use JavaScript to mimic desktop widgets such as menus, tree views, rich text fields, and tab panels. These widgets are typically composed of {{ HTMLElement("div") }} and {{ HTMLElement("span") }} elements that do not, by nature, offer the same keyboard functionality that their desktop counterparts do. This document describes techniques to make JavaScript widgets accessible with the keyboard.
## Using tabindex
By default, when people use the tab key to browse a webpage, only interactive elements (like links, form controls) get focused. With the `tabindex` [global attribute](/en-US/docs/Web/HTML/Reference/Global_attributes), authors can make other elements focusable, too. When set to `0`, the element becomes focusable by keyboard and script. When set to `-1`, the element becomes focusable by script, but it does not become part of the keyboard focus order.
The order in which elements gain focus when using a keyboard, is the source order by default. In exceptional circumstances, authors may want to redefine the order. To do this, authors can set `tabindex` to any positive number.
> [!WARNING]
> Avoid using positive values for `tabindex`. Elements with a positive `tabindex` are put before the default interactive elements on the page, which means page authors will have to set (and maintain) `tabindex` values for all focusable elements on the page whenever they use one or more positive values for `tabindex`.
The following table describes `tabindex` behavior in modern browsers:
<table>
<thead>
<tr>
<th><code>tabindex</code> attribute</th>
<th>Focusable with mouse or JavaScript via <code>element.focus()</code></th>
<th>Tab navigable</th>
</tr>
</thead>
<tbody>
<tr>
<td>not present</td>
<td>Follows the platform convention of the element (yes for form controls, links, etc.).</td>
<td>Follows the platform convention of the element.</td>
</tr>
<tr>
<td>Negative (i.e., <code>tabindex="-1"</code>)</td>
<td>Yes</td>
<td>No; author must focus the element with <a href="/en-US/docs/Web/API/HTMLElement/focus"><code>focus()</code></a> in response to arrow or other key presses.</td>
</tr>
<tr>
<td>Zero (i.e., <code>tabindex="0"</code>)</td>
<td>Yes</td>
<td>In tab order relative to element's position in document (note that interactive elements like {{HTMLElement('a')}} have this behavior by default, they don't need the attribute).</td>
</tr>
<tr>
<td>Positive (e.g., <code>tabindex="33"</code>)</td>
<td>Yes</td>
<td><code>tabindex</code> value determines where this element is positioned in the tab order: smaller values will position elements earlier in the tab order than larger values (for example, <code>tabindex="7"</code> will be positioned before <code>tabindex="11"</code>).</td>
</tr>
</tbody>
</table>
### Non-native controls
Native HTML elements that are interactive, like {{ HTMLElement("a") }}, {{ HTMLElement("input") }} and {{ HTMLElement("select") }}, are already accessible by keyboards, so to use one of them is the fastest path to make components work with keyboards.
Authors can also make a {{ HTMLElement("div") }} or {{ HTMLElement("span") }} keyboard accessible by adding a `tabindex` of `0`. This is particularly useful for components that use interactive elements that do not exist in HTML.
### Grouping controls
For grouping widgets such as menus, tablists, grids, or tree views, the parent element should be in the tab order (`tabindex="0"`), and each descendant choice/tab/cell/row should be removed from the tab order (`tabindex="-1"`). Users should be able to navigate the descendant elements using arrow keys. (For a full description of the keyboard support that is normally expected for typical widgets, see the [WAI-ARIA Authoring Practices](https://www.w3.org/WAI/ARIA/apg/).)
The example below shows this technique used with a nested menu control. Once keyboard focus lands on the containing {{ HTMLElement("ul") }} element, the JavaScript developer must programmatically manage focus and respond to arrow keys. For techniques for managing focus within widgets, see "Managing focus inside groups" below.
```html
<ul id="mb1" tabindex="0">
<li id="mb1_menu1" tabindex="-1">
Font
<ul id="fontMenu" title="Font" tabindex="-1">
<li id="sans-serif" tabindex="-1">Sans-serif</li>
<li id="serif" tabindex="-1">Serif</li>
<li id="monospace" tabindex="-1">Monospace</li>
<li id="fantasy" tabindex="-1">Fantasy</li>
</ul>
</li>
<li id="mb1_menu2" tabindex="-1">
Style
<ul id="styleMenu" title="Style" tabindex="-1">
<li id="italic" tabindex="-1">Italics</li>
<li id="bold" tabindex="-1">Bold</li>
<li id="underline" tabindex="-1">Underlined</li>
</ul>
</li>
<li id="mb1_menu3" tabindex="-1">
Justification
<ul id="justificationMenu" title="Justification" tabindex="-1">
<li id="left" tabindex="-1">Left</li>
<li id="center" tabindex="-1">Centered</li>
<li id="right" tabindex="-1">Right</li>
<li id="justify" tabindex="-1">Justify</li>
</ul>
</li>
</ul>
```
#### Disabled controls
When a custom control becomes disabled, remove it from the tab order by setting `tabindex="-1"`. Note that disabled items within a grouped widget (such as menu items in a menu) should remain navigable using arrow keys.
## Managing focus inside groups
When a user tabs away from a widget and returns, focus should return to the specific element that had focus, for example, the tree item or grid cell. There are two techniques for accomplishing this:
1. Roving `tabindex`: programmatically moving focus
2. `aria-activedescendant`: managing a 'virtual' focus
### Technique 1: Roving tabindex
Setting the `tabindex` of the focused element to "0" ensures that if the user tabs away from the widget and then returns, the selected item within the group retains focus. Note that updating the `tabindex` to "0" requires also updating the previously selected item to `tabindex="-1"`. This technique involves programmatically moving focus in response to key events and updating the `tabindex` to reflect the currently focused item. To do this:
Bind a key down handler to each element in the group, and when an arrow key is used to move to another element:
1. programmatically apply focus to the new element,
2. update the `tabindex` of the focused element to "0", and
3. update the `tabindex` of the previously focused element to "-1".
### Technique 2: `aria-activedescendant`
This technique involves binding a single event handler to the container widget and using the `aria-activedescendant` to track a "virtual" focus. (For more information about ARIA, see this [overview of accessible web applications and widgets](/en-US/docs/Web/Accessibility/Guides/Accessible_web_applications_and_widgets).)
The `aria-activedescendant` property identifies the ID of the descendant element that currently has the virtual focus. The event handler on the container must respond to key and mouse events by updating the value of `aria-activedescendant` and ensuring that the current item is styled appropriately (for example, with a border or background color).
## General guidelines
### Usage of focus events
- Do not dispatch the [`focus`](/en-US/docs/Web/API/Element/focus_event) event to send focus to an element. DOM focus events are considered informational only: they are generated by the system after something is focused, but not actually used to set focus. Use `element.focus()` instead.
- Do listen for the [`focus`](/en-US/docs/Web/API/Element/focus_event) and [`blur`](/en-US/docs/Web/API/Element/blur_event) events to track focus changes. Don't assume that all focus changes will come via key and mouse events: assistive technologies such as screen readers can set the focus to any focusable element. If you want to track the focus status for the whole document, you can use the [`document.activeElement`](/en-US/docs/Web/API/Document/activeElement) to get the active element, or [`document.hasFocus`](/en-US/docs/Web/API/Document/hasFocus) to make sure if the current document has focus.
### Ensure that keyboard and mouse produce the same experience
To ensure that the user experience is consistent regardless of input device, keyboard and mouse event handlers should share code where appropriate. For example, the code that updates the `tabindex` or the styling when users navigate using the arrow keys should also be used by mouse click handlers to produce the same changes.
### Ensure that the keyboard can be used to activate element
To ensure that the keyboard can be used to activate elements, any handlers bound to mouse events should also be bound to keyboard events. For example, to ensure that the Enter key will activate an element, if you have an `onclick="doSomething()"`, you should bind `doSomething()` to the key down event as well: `onkeydown="event.code === "Enter" && doSomething();"`.
### Always draw the focus for tabindex="-1" items and elements that receive focus programmatically
Ensure that focused elements have a focus ring. This can be done using the CSS {{cssxref("outline")}} property, which should not be unconditionally set to `none`—if you want to prevent unnecessary focus rings being displayed, use the {{cssxref(":focus-visible")}} pseudo-class.
### Prevent used key events from performing browser functions
If your widget handles a key event, prevent the browser from also handling it (for example, scrolling in response to the arrow keys) by using your event handler's return code. If your event handler returns `false`, the event will not be propagated beyond your handler.
For example:
```html
<span tabindex="-1">…</span>
```
```js
span.onkeydown = handleKeyDown;
```
If `handleKeyDown()` returns `false`, the event will be consumed, preventing the browser from performing any action based on the keystroke.
### Don't rely on consistent behavior for key repeat, at this point
Unfortunately `onkeydown` may or may not repeat depending on what browser and OS you're running on.
|
---
title: Cognitive accessibility
slug: Web/Accessibility/Guides/Cognitive_accessibility
page-type: guide
sidebar: accessibilitysidebar
---
Cognitive accessibility covers accessibility considerations for people with cognition and learning disabilities. This document introduces cognitive accessibility and improving accessibility of the web for people with cognitive and learning differences.
Cognitive impairment refers to a broad range of disabilities, from people with intellectual disabilities who may have the most-limited capabilities, to age-related issues with thinking and remembering. The range includes people with mental illnesses, such as depression and schizophrenia. It also includes people with learning disabilities, such as dyslexia and attention deficit hyperactivity disorder (ADHD).
Though there is a lot of diversity within clinical definitions of cognitive impairments, people with them experience a common set of functional problems. These problems include difficulty with understanding content, remembering how to complete tasks, and confusion caused by inconsistent or non-traditional web page layouts. In this document, we focus on steps developers should take to improve the cognitive accessibility of their websites and applications.
## Overview
Cognitive and intellectual disabilities cover a large spectrum, and may be momentary, temporary, or permanent conditions. For example, dementia and Alzheimer's are permanent cognitive impairments that get progressively worse. Other permanent cognitive impairments include aphasia, speech and language, autism, ADD/ADHD, dyslexia, and dyscalculia.
An example of a temporary cognitive impairment could be people affected by substances such as alcohol or drugs. Another form it can take is depression, such as when mourning the loss of a loved one, or being momentarily saddened by a tweet or video they just saw online. A third example could be sleep deprivation.
It may seem like an overwhelming challenge to address the wide range of cognitive differences, especially when solutions for two different people may be conflicting. One way to handle this is to focus on cognitive skills. Cognitive skills include:
- attention
- memory
- processing speed
- time management
- letters and language
- numbers symbols and math
- understanding and making choices
A solid approach to providing accessible solutions for people with cognitive impairments includes:
- delivering content in more than one way, such as by text-to-speech or by video;
- providing easily-understood content, such as text written using plain-language standards;
- focusing attention on important content;
- minimizing distractions, such as unnecessary content or advertisements;
- providing consistent web page layout and navigation;
- incorporating familiar elements, such as underlined links that are blue when not visited and purple when visited;
- dividing processes into logical, essential steps with progress indicators;
- making website authentication as easy as possible without compromising security; and
- making forms easy to complete, such as with clear error messages and error recovery.
## WCAG Guidelines
WCAG, Web Content Accessibility Guidelines, includes several guidelines to improve cognitive accessibility. These guidelines are published by the Web Accessibility Initiative (WAI) of the World Wide Web Consortium (W3C), the main international standards organization for the Internet. This group is also responsible for the [Accessible Rich Internet Application (ARIA)](/en-US/docs/Web/Accessibility/ARIA/Guides) guidelines.
WCAG are guided by four principles: websites must be Perceivable, Operable, Understandable, and Robust. To this end, they define 17 specific guidelines, of which six are especially relevant for cognitive accessibility.
All of the following guidelines help more than just people with cognitive disabilities. For example, being able to extend the expiration time on an application requiring an authentication code sent to a mobile device via text message helps with the following scenarios:
- People with attention or anxiety disorders.
- People who have a poor short-term memory, or who are multitasking.
- People who are less technologically literate.
- People who have poor wireless reception.
- People who have motor control issues.
## Adaptability
[Guideline 1.3](https://www.w3.org/WAI/WCAG21/Understanding/adaptable) states "content should be **adaptable**". Create content that can be presented in different ways without losing information or structure. For example, provide {{glossary('responsive web design', 'responsive')}} layouts, with a single column mobile design.
All information, including structure and relationships conveyed through the presentation, should be available in a form that can be perceived by all users to achieve this goal. For example, the information could be spoken aloud via a narration tool. Making your content capable of being understood by the software is a good way to help ensure it can be used by alternate presentational modes.
## Time
It is important to allow users the time they require to complete tasks. [Guideline 2.2](https://www.w3.org/WAI/WCAG21/Understanding/enough-time) states "provide users enough **time** to read and use content".
A **time limit** is any process that happens without user initiation after a set time or on a periodic basis, such as being logged out after 30 minutes or having 15 minutes to make a purchase. People with cognitive disabilities may require more time to read content, or to perform functions such as filling out forms. Solutions include providing users enough additional time to complete tasks or eliminate time constraints altogether.
### Timers
Options for adjusting time requirements include:
- Allowing the user to turn off or adjust the time to at least 10 times the original limit before encountering it.
- Alerting the user and providing a buffer of at least 20 seconds to extend the timeout duration by a factor of 10 with an action, such as hitting the space bar.
Provide a toggle on content that allows users to enable a longer session time limit, or no session time limit at all. Examples of timed content include forms, timed reading exercises, and training materials. If the time limit is longer than 20 hours, accommodations are not required.
### Moving, blinking, scrolling
It is important not to distract users, especially ones with cognitive disabilities.
If moving, blinking, scrolling, or auto-updating information starts automatically, lasts more than five seconds, and is presented in parallel with other content, the user must able to pause, stop, hide or control it, unless it's an essential functionality. "Essential" means that removing the moving, blinking, scrolling, or auto-updating information would fundamentally change the meaning of the content and/or functionality, **and** information and functionality cannot be achieved in another way that would conform. This includes animated GIFs, if the gif animates for more than 5 seconds.
Additional timing criteria to consider are:
- People who have cognitive or language limitations may need more time to read and to understand. For improved usability remove any time limit. Timed content should also be avoided, with exceptions for non-interactive synchronized media and real-time events.
- People with attention deficit disorders should be able to focus on content without distractions. The user should be able to postpone or suppress interruptions, except situations involving alerting a person to an emergency. This provides access to people with cognitive disabilities by enabling them to focus on the main purpose of the content. Enable the user to postpone content updates by providing a way to request content updates rather than updating automatically. Also, enable a way to make nonessential alerts optional.
- Ensure that people can continue an activity without loss of data after re-authenticating an expired session, for example, saving the state of a questionnaire. Make sure to save data in such a way that it can be modified after a user re-authenticates. Before re-authenticating, encode the data as hidden or encrypted.
- Providing warnings about inactivity that could result in data loss. When a timeout is used, tell people exactly how much time will cause the session to time out and result in lost data. The exception to this is preserving data for more than 20 hours when no actions are taken.
## Navigation
[Guideline 2.4](https://www.w3.org/WAI/WCAG21/Understanding/navigable) states "provide ways to help users navigate, find content, and determine where they are," and provides 10 guidelines to ensure the site is navigable and content is findable:
### Include a `<title>`
Make sure to include a {{HTMLElement('title')}} for the document, as titles provide a quick and easy to reference description of the screen's main point. People with cognitive disabilities, limited short-term memory, and reading disabilities all benefit from being able to identify the purpose of content this way.
### Heading and labels
Include clear and descriptive headings so users can easily find information and understand relationships between different content sections. Descriptive labels help users identify specific components within the content. People who read slowly and people with limited short-term memory benefit when section titles make it possible to predict what each section contains.
### Section headings
Headings help define overall organization of page content. They help facilitate navigation through page content sections, and provide a mechanism to aid comprehension. Examples of headings include chapters, sections and subsections of content, and so on.
Headings are more obvious navigational aids compared to other methods to identify page content sections (borders, whitespace, horizontal rules, etc.).
### Multiple ways to find content
Different users prefer different methods of finding information, so it is important to provide multiple ways for users to locate content on your site.
Providing more than one way to navigate your site can help people find information faster. Some users may prefer a table of contents, site map, or search functionality rather than reading and traversing through several pages to find what they need. Others may prefer to explore the site in a sequential manner, moving from page to page in order to best understand the site's layout, content, and concepts.
### Ability to bypass blocks of content
Providing a mechanism, such as a [skip link](/en-US/docs/Web/HTML/Reference/Elements/a#skip_links), to bypass blocks of content that are repeated on multiple web pages.
### Focus order makes sense
The order of focus for interactive elements should make sense. To achieve this, the DOM order should match the visual order, which in turn should match the tabbing order. If the tab order jumps around, especially in a way that does not match the visual order when navigating with a keyboard, users can become disoriented.
### Focused elements should be visibly focused
When a user navigates using a keyboard, the UI should make it obvious which element currently has focus. Don't alter or remove the browser's default {{cssxref(":focus")}} styling, unless you're making focus even more obvious.
### Link text conveys meaning
The link's text should clearly and concisely communicate what the user should expect to be navigated to next if they choose to activate it. Poorly phrased link text may confuse users as to its purpose or destination.
Some forms of assistive technology allow users to navigate by lists of all the links present on the page. Links will be removed from the context of their surrounding non-link content, making the need for understandable link text even more important. An example of a poor experience is a page full of links whose text reads, "Click here". Without indicating where "here" will take you, the link's purpose is unclear.
For screen readers, it is vital that linked text describes the purpose of each link. If you have added content to links for screen readers, and that content is verbose and potentially confusing to sighted readers, consider clipping the added text to visually hide it from those not using assistive technologies.
### Current location is available
Users should be able to orient themselves within a site or application. This is especially important and helpful for people with short attention spans who may become confused when following a long series of navigation steps.
All users benefit from information about where they are in a site's hierarchy, especially for sites or applications with large amounts of content or many subsections. [Breadcrumbs](/en-US/docs/Glossary/Breadcrumb), [site maps](/en-US/docs/Glossary/Site_map), and identifying the current page in the navigation as "current" are all techniques that help communicate the current location.
## Readability
[Guideline 3.1](https://www.w3.org/WAI/WCAG21/Understanding/readable) states "make text content readable and understandable". For some users, it is difficult to infer the meaning of a word or phrase from context, especially when the word or phrase is used in an unusual way, or has been given a specialized meaning.
For these users, the ability to read and understand may depend on the availability of specific definitions or the expanded forms of acronyms or abbreviations. Some users may experience great difficulty in recognizing written words yet they understand extremely complex and sophisticated documents when the text is read aloud, or when key processes and ideas are illustrated visually.
### Declare the language of the page and any content not in that main language
The language of every page must be declared by using the [`lang`](/en-US/docs/Web/HTML/Reference/Global_attributes/lang) attribute on the {{HTMLElement('html')}} element. Include the `lang` attribute again on text that is in a language other than the main language of the document.
Proper use of `lang` allows some screen readers to announce the text properly when converting it into synthetic speech. It also helps people who use text-to-speech software.
### Define unusual words and word usage
Some disabilities make it difficult to understand nonliteral word usage, such as idioms, colloquialisms, and specialized jargon. Non-native language speakers may also struggle with these terms. If a word or phrase has a unique meaning, in the document provide a definition inline or linked, within a glossary, or to an online dictionary. If a word or phrase is used to mean more than one thing, define each use.
### Define abbreviations
Abbreviations can be confusing for people who:
- Have difficulty decoding words.
- Have limited memory.
- Have difficulty using context to aid understanding.
- Rely on screen magnifiers (which often reduce contextual cues).
Provide an expanded form of the abbreviation the first time it is used, followed by the abbreviation placed within an {{HTMLElement('abbr')}} element. If an abbreviation has no expanded form, or is an abbreviation for a word that is not in the document's main language (such as Latin), explain its meaning. Also, consider using [ruby text](/en-US/docs/Web/HTML/Reference/Elements/ruby) for initialism (pronunciation of acronyms).
### Reading level
Content should be written as clearly as possible. A good rule to go by is to make content simple enough that it can be understood the first time. Methods to achieve this include:
- Using short, simple words.
- Writing short sentences.
- Using active voice in the present tense.
- Using correct grammar and spelling.
It helps users with cognitive disabilities to provide a text summary (sometimes referred to as a TL;DR, or "too long; didn't read") at a low reading level. Another technique you can use is providing accompanying visuals to help explain ideas, events, and processes.
There are tools that can rate the level of your content. For example, this document has an average grade level of about 11. This means it should be easily understood by a native English speaker aged 16 to 17. Some tools can even provide suggestions to help simplify it.
### Pronunciation
There are multiple techniques that can help teach people how to pronounce words:
- Provide the pronunciation immediately following the word.
- Link to a list of pronunciations.
- Provide a glossary with pronunciation.
- Use the {{HTMLElement('ruby')}} element to illustrate how a word is pronounced.
Providing guidance on how to pronounce words helps many different kinds of people, including those who prefer to read aloud, non-native language speakers, and people who are unfamiliar with the meaning of a term in context.
Another solution is to use glyphs or diacritical marks to illustrate pronunciation. However, if this technique is used, there must be a mechanism to turn it off. Further, it is helpful to link to a guide to the marks being used, as their meaning may not be obvious.
## Predictability
WCAG [Guideline 3.2](https://www.w3.org/WAI/WCAG21/Understanding/predictable) states "make web pages appear and operate in predictable ways". This is a tenet of good user experience design. Consistency is especially important for people with cognitive difficulties. This includes consistency in page layout and predictable interactive components.
### Use activation, not focus to change context
Creating a change in context should be intentional. Because of this, when a UI feature receives [focus](/en-US/docs/Web/API/HTMLElement/focus), it should not trigger further user-facing actions. Rather, users should need to "activate" a feature to trigger the change.
### Change setting based on an active request
Form control operation and data entry should result in predictable behavior. Changes in context can confuse users with cognitive disabilities, and should therefore only occur when it is clear that such a change will happen in response to the user's action.
Changing state should require intentional user action. Examples of this are checking a checkbox, entering data or changing a select option. Also be sure to provide a submit button to initiate the change of context, and describe what will happen before the change is made.
### Keep navigation consistent throughout the site
Keep the navigation order consistent between pages. For example, if you have a navigation bar on multiple pages, make that navigation uniform across the site with the same links in the same location. This doesn't just apply to navigation: present all repeated components in the same relative order each time they appear.
### Provide consistent labeling
Identical functions should have similar labels every time they are utilized. Consistent button labels, alternative text for icons, and iconography for similar interactions and so on, even on different sections of your site, help all your users.
### Be consistent and predictable, and use norms
While unlabeled iconography is not the most effective method of conveying information, keeping the use of the icons (and if labeled, their label text) consistent helps people to understand what the icon represents. Similarly, don't change defaults like the browser's back button. If you need to redirect a user, let the user know about it beforehand.
## Input Assistance
[Guideline 3.3](https://www.w3.org/WAI/WCAG21/Understanding/input-assistance) helps to ensure accurate data entry, stating "help users avoid and correct mistakes". While we all make mistakes, some people are more likely to make mistakes, less likely to notice a mistake, or have a harder time correcting a mistake once they make one.
Input Assistance guidelines aim to reduce the likelihood that users, especially those with disabilities, make a mistake, and, if they do make a mistake, increase the likelihood that they see and comprehend the error message and can successfully fix any errors.
### Convey automated error detection
Users need to be alerted to the error and informed of what is wrong. If there is client side error detection, observe the following guidelines to make the error as effective as possible when conveyed to the user:
- The error must be described in the text.
- Ensure that the error message is as specific as possible.
- Provide text to identify incomplete required fields and text descriptions if a value entered is invalid.
- If the error prevented a form submission, focus on the error. If multiple errors are present, provide a summary, with each error linking to the related input.
- Include text along with use of icons, images, color and so on. Some people have difficulty understanding the meaning of icons and other visual cues.
- Other people may have difficulty understanding the text version of your error message. For these people, also provide things like icons and colors.
- Also, provide feedback on when there is a successful form submission.
### Provide instructions for user input
Start the form with text instructions on how to operate it. Include labels or instructions when users need to input information, using the {{HTMLElement('label')}}, {{HTMLElement('fieldset')}}, and {{HTMLElement('legend')}} elements to do so.
Labels should be descriptive and positioned close to the input they relate to. When requiring a specific format for input, provide an example formatted in the proper way. Additionally, consider performing server-side validation to help format input data, to aid in the ease of user input.
If a form control is required, indicate it both visually and [via code](/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-required). If a form control changes context, describe what will happen in a way that the user will understand it before they cause the context change to happen.
### Error Suggestion
Provide suggested input to the user if an input error is automatically detected and suggestions for correction are known (unless doing so would jeopardize the security or purpose of the content).
### Prevent catastrophes
For submissions that cause, or can lead to, legal, financial, or other significant consequences, ensure that the submissions can be reviewed, confirmed, and/or are reversible.
Data entered by the user should be checked for errors before submission, and the user should be given the opportunity to correct them. The user should be able to review, confirm, and correct information before final submission. Also, be sure to include a confirmation checkbox in addition to a submit button.
If a submission causes a legal or financial transaction to occur, provide a stated time within which the request can be amended or canceled by the user.
### Provide help
Context-sensitive help should be made available. If a form requires text input, provide form instructions describing the purpose and the necessary input. Include spell checking and suggestions for long-form text input, as well as links to help and support material. If a specific data format is expected for input, provide an example.
## Notes
The above are good design practices. They will benefit everyone.
- Many people with cognitive impairments also have physical disabilities. Websites must conform with the W3C's [Web Content Accessibility Guidelines](https://www.w3.org/WAI/standards-guidelines/wcag/).
- The W3C's [Cognitive and Learning Disabilities Accessibility Task Force](https://www.w3.org/WAI/GL/task-forces/coga/) produces web accessibility guidelines for people with cognitive impairments.
- WebAIM has a [Cognitive page](https://webaim.org/articles/cognitive/) of relevant information and resources.
- The United States Centers for Disease Control estimate that, as of 2018, 1 in 4 U.S. citizens have a disability and, of them, [cognitive impairment is the most common for young people](https://archive.cdc.gov/www_cdc_gov/media/releases/2018/p0816-disability.html).
- In the U.S., "intellectual disabilities" used to be called "mental retardation". In the U.K., "intellectual disabilities" is commonly called "learning disabilities" or "learning difficulties".
## See also
- [Accessibility Guidelines](https://extensionworkshop.com/documentation/develop/build-an-accessible-extension/)
- [What is accessibility](/en-US/docs/Learn_web_development/Core/Accessibility/What_is_accessibility)
- [Accessibility for seizure disorders](/en-US/docs/Web/Accessibility/Guides/Seizure_disorders)
- [Understanding WCAG Guidelines](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG)
- [Accessibility overview](/en-US/docs/Learn_web_development/Core/Accessibility)
- [Web Content Accessibility Guidelines](https://www.w3.org/WAI/standards-guidelines/wcag/), including [cognitive accessibility guidelines](#wcag_guidelines)
- [The W3C's Cognitive and Learning Disabilities Accessibility Task Force](https://www.w3.org/WAI/GL/task-forces/coga/)
- [WebAIM Cognitive information](https://webaim.org/articles/cognitive/)
- [CDC information on disabilities](https://www.cdc.gov/disability-and-health/)
|
---
title: "Web Accessibility: Understanding Colors and Luminance"
short-title: Colors and Luminance
slug: Web/Accessibility/Guides/Colors_and_Luminance
page-type: guide
sidebar: accessibilitysidebar
---
While understanding color, luminance, and saturation is important for design and readability for all sighted users, they are essential for those with reduced vision and color-deficient vision and those with specific neurological, cognitive, and other impairments.
Accessibility guidelines define adequate [color contrast](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Perceivable/Color_contrast) for sighted users with reduced vision, as well as guidelines intended to help users with color insensitive vision, commonly referred to as "color blindness". Understanding color is also important in preventing [seizures and other physical reactions](/en-US/docs/Web/Accessibility/Guides/Seizure_disorders) in people with vestibular disorders or other neurological disorders.
## Overview
The choice of colors and their use is a significant component of accessibility. On the surface, the subject seems simple. Still, it is a complex subject because color perception is as much about the physiology of the eye and human brain processing as it is about light emitting from a computer screen.
### Environment and perception
Environment matters. Perception of color in a well-lit room will be different than perception of that same color on that same computer screen in a dark room. Regarding accessibility, using certain color combinations has more impact than others. Font size, [font style](https://www.nngroup.com/articles/glanceable-fonts/) (some fonts are so thin or fancy that they present accessibility problems on their own), background color, the size of the background space around the text, even pixel densities, and more all affect how color is delivered from the screen.
A viewer's distance from the screen, the ambient background, the health of his eyes, and more all affect how that color is received by the viewer. How the viewer perceives color after it gets to their eyes is yet another matter, and can be affected by overall health. Fortunately, there are [media queries](/en-US/docs/Web/CSS/Reference/At-rules/@media) that enable developers to provide styles based on user preferences, including [contrast](/en-US/docs/Web/CSS/Reference/At-rules/@media/prefers-contrast) and [color scheme](/en-US/docs/Web/CSS/Reference/At-rules/@media/prefers-color-scheme) preferences.
When supported, the [Ambient Light Sensor](/en-US/docs/Web/API/AmbientLightSensor) interface returns the current light level or illuminance of the ambient light around the hosting device, enabling a web page to be aware of any change in the light intensity, and consequently, adjust the text accordingly. Additionally, the above media queries enable developers to provide alternative user experiences when user preferences indicate preferred contrast levels, automatically adjusting levels depending on the user's location and what kind of screen they are using.
### Luminance and perception
Color, contrast, and luminance are the most central and critical concepts to creating accessible web content with color. Luminance is of particular importance, however, because understanding what it is and how it is employed enables accessibility for those who are color-blind, as well as those who can perceive color. The luminance contrast enables the color blind to distinguish dark from light.
Luminance must be established before the contrast may be. When speaking of color contrast, W3C formulas are incorporating luminance, not just the colors ("hues") themselves.
### Terminology
Terminology can be confusing because different terms often describe the same thing. "Luminance" and "Saturation" are particularly important to get right. For example, "saturation" is known as "chroma" in some circles. In others, "chroma" and "saturation" are two different concepts. The "L" in the HSL color space is sometimes referred to as "luminosity," and other times as "lightness." Even something seemingly simple, like naming common colors, can be open to debate. For example, the color "crimson red" may be described in hex values as `#990000` by some and `#DC143C` by others. For this document, we'll use terminology as it is defined on the CSS {{cssxref("named-color")}} page.
When working with color, it's important to know which "color space" you are working in, as different color spaces map to different measurement systems.
In color printing, your printer likely has cyan, magenta, yellow, and black (CMYK) ink cartridges. CMYK is a subtractive model wherein the four inks _remove_ specific wavelengths of light, reflecting only the narrow range each is associated with. RGB is an additive color model that adds different proportions of red, green, and blue lights.
Currently, the {{glossary("RGB", "RGB color space")}} predominates as the space web developers work in. While HEX, RGB, and HSL color spaces are notated differently, browsers automatically convert values between these color notations. [CSS color modules](/en-US/docs/Web/CSS/Guides/Colors) provide additional color spaces. Still, because of the current domination of the RGB color space in measuring color output, most calculations in this document are presumed to be in the RGB color space and, very specifically, in the sRGB color space.
## The sRGB color space
Color has many ways of being defined, as is apparent in the {{cssxref("<color>")}} data type, including RGB, RGB decimal, RGB percent, HSL, HWB, LCH, Lab, and CMYK, among others.
For digital concerns, much of the technology has historically resided in the RGB color space. The RGB color model is extended to include "alpha" — RGBA — to allow specification of the opacity of a color. Other methods for measuring color involve measurements using other color spaces and are supported in modern displays and browsers. Still, color measurements in the RGB color space predominate, including in video production.
Technologies, such as [OpenGL](https://en.wikipedia.org/wiki/OpenGL) and [Direct3D](https://en.wikipedia.org/wiki/Direct3D) incorporate support for the sRGB gamma curve, although some articles for OpenGL reference use of RGBA rather than sRGB. WebGL is usually in the RGBA format; see an example of how it is used in "[Clearing with colors](/en-US/docs/Web/API/WebGL_API/By_example/Clearing_with_colors)".
### CSS color values
It's important to know that there are variations even within one {{glossary("color space")}}, such as the {{glossary("RGB")}} color space. For example, variations of the RGB color space include **RGB**, **sRGB**, **Adobe RGB**, **Adobe Wide Gamut RGB**, and **RGBA**, among others.
These are examples of the CSS notations used to define a color. Here the example color for each is a fully opaque magenta:
```css
/* named color */
color: magenta;
/* sRGB value with percentage values */
color: rgb(100% 0% 100%);
color: rgb(100% 0% 100% / 100%);
/* by sRGB numeric values */
color: rgb(255 0 255);
color: rgb(255 0 255 / 1);
/* legacy rgb and rgba notation */
color: rgb(100%, 0%, 100%);
color: rgba(255, 0, 255, 1);
/* by sRGB value in hex */
color: #f0f; /* #rgb, a shorthand for #rrggbb */
color: #ff00ff; /* #rrggbb */
color: #f0ff; /* #rgba */
color: #ff00ffff; /* #rrggbbaa */
/* by HSL representation of the sRGB value */
color: hsl(300 100% 50%);
color: hsl(300deg 100% 50% / 100%);
/* by HWB representation of the sRGB value */
color: hwb(300deg 0% 0%);
color: hwb(300 0% 0% / 1);
/* by Lab representation of the sRGB value */
color: lab(60 93.56 -60.5);
color: lab(60 93.56 -60.5 / 1);
/* representation in the CIELAB color spaces */
color: oklch(0.7 0.32 328.37);
color: oklch(0.7 0.32 328.37 / 1);
/* color() function in the XYZ color space */
color: color(xyz-d65 0.59 0.28 0.96);
color: color(xyz-d65 0.59 0.28 0.96 / 1);
```
The first example uses one of the defined {{cssxref("named-color")}}s.
We can set the sRGB values directly as a percentage, with 0% being off (black) and 100% being the full value for that color. The values are in the order of red, green, and blue. We can also set the sRGB values directly by a number from 0 to 255.
Shown after that are hex color values. Hexadecimal is a numbering system with base-16, where the 0-255 integer is represented by two digits ranging from 0-15 using the digits 0-9 and a-f for 10-15. Thus, `ff` = `255`, `00` = `0`, and `d5` = `200`. The '#' symbol precedes the color to indicate the value is hex.
If all values are pairs of identical digits, the value can be represented by single digits that the browser will duplicate. Thus `f00` is the same as `ff0000`. If a fourth set of numbers is present, that value is the A in RGBA, the alpha channel defining transparency in terms of the opacity value of the color. A higher value means the color is more opaque and therefore, less transparent. In the examples above, the alpha value is `f`, `ff`, `1`, and `100%` for fully opaque.
The example also shows the legacy syntax for both [`rgb()` and `rgba()`](/en-US/docs/Web/CSS/Reference/Values/color_value/rgb#examples). The legacy syntax for color functions is comma-separated, with a separate function for when the alpha channel is included. New color functions only have one syntax with space-separated (rather than comma-separated) values, with the alpha channel, if present, being preceded by a slash. Modern syntax allows for mixing numbers and percents and supports the `none` keyword; the comma-separated legacy syntax does not.
The following examples show "HSL", which stands for _Hue, Saturation, and Lightness_. HSL color values are considered by many to be more intuitive than RGB values. The color produced from the settings are still in the sRGB colorspace, but {{cssxref("color_value/hsl")}} is an intuitive syntax for many. The hue is adjusted as an angle, and it is easy to create a user interface using a knob or circular control to adjust the hue. Do note that HSL colors incorporate _lightness_, not _luminance_, which is a significant consideration.
The next example shows "HWB" which stands for _Hue, Whiteness, and Blackness_. With both `hsl()` and {{cssxref("color_value/hwb")}} the first value can be a {{cssxref("number")}} or an {{cssxref("angle")}} value. When unitless, the value is interpreted as `deg` degrees.
There are several other color functions and color spaces. The last three examples demonstrate representing magenta using the {{cssxref("color_value/lab")}}, {{cssxref("color_value/oklch")}}, and {{cssxref("color_value/color")}} color functions.
### Conversions
As we saw, one color within the same color space may be expressed in many ways. Looking at how the RGB color space is used to describe the color "magenta", you can see that the same color may be expressed in a shorthand, three-digit hex number that converts to an rgb value as a six-digit hex number that also converts to the same rgb value, or as a rgba value, expressed in percentages.
RGB is hardware-oriented, reflecting the use of CRTs. Many developers and designers prefer the intuitiveness of {{cssxref("color_value/hsl")}} notation. Fortunately, browsers convert from RGB to HSL automatically, and shift-clicking on colors in browser developer tools provides conversion functionality.
In addition to developer tools, many tools can convert RGB to HSL for you and provide both the RGB hexadecimal and CSS function syntax. A great example of a tool that converts colors for you is Tom Jewett's "[mini color selector](https://colortutorial.design/microColorsC.html)" with HSL, RGB, and Hex options for checking contrast in the browser. Note that developer tools color pickers and this tool all provide WCAG [color contrast](https://webaim.org/resources/contrastchecker/) values.

As noted earlier, the [CSS color module](/en-US/docs/Web/CSS/Guides/Colors) includes adding additional colorspaces, including {{cssxref("color_value/lch")}} and {{cssxref("color_value/oklch")}} functional color notation and the {{cssxref("color_value/lab")}} and {{cssxref("color_value/oklab")}} color coordinate systems, which can specify any visible color. That said, sRGB is still the default and preferred colorspace for accessibility because of its ubiquity.
Where accessibility is concerned, however, standards and guidelines are currently written predominantly using the sRGB color space, especially as it applies to color contrast ratios.
> [!NOTE]
> Almost all systems used today to view Web content assume sRGB encoding. Unless it is known that another color space will be used to process and display the content, authors should evaluate using sRGB colorspace. If using other color spaces, apply the principles of [minimum contrast ratios](https://webaim.org/articles/contrast/#sc143).
### Querying color values
The {{domxref('Window.getComputedStyle()')}} method returns values using the RGB Decimal Reference scale or via `color(srgb...)`. For example, calling `Window.getComputedStyle()` on a `<div>` with `background-color: red` set on it returns the computed background color as `rgb(255, 0, 0)` — the RGB Decimal reference. However, when [using relative colors](/en-US/docs/Web/CSS/Guides/Colors/Using_relative_colors) (for example `background-color: rgb(from blue 255 0 0)`), calling `Window.getComputedStyle()` returns the computed background color as `color(srgb 1 0 0)`. Being tied to computer hardware, `Window.getComputedStyle()` measures color in terms of RGB, not how the human eye perceives color.
### Red / green color blindness
Protanopia is a color vision deficiency in which the eye has no red cones; sRGB can still be perceived via green cones, though darker than normal vision. Both protan (red deficient) and deutan (green deficient) deficiencies cause difficulty distinguishing _between_ red and green.
Developer tools can help simulate color vision differences right in your browser. For example, Firefox's Accessibility Inspector enables simulating protanopia, deuteranopia, tritanopia, achromatopsia, and contrast loss right in the accessibility panel.

## Luminance and Contrast
### Contrast
The contrast between colors ("hues") is a critical component, but the use of color ("hues") alone is not enough to create accessible content. As mentioned before, any calculation of contrast must include luminance.
In addition, the "shape" of the text itself will matter. Thin letters will be harder to read than thick ones; all typefaces need space to "breathe" for human perception.
### Contrast and font size
[WCAG contrast guidelines](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Perceivable#guideline_1.4_make_it_easier_for_users_to_see_and_hear_content_including_separating_foreground_from_background) define "large" text as text that is `18pt` (approximately `24px`) or larger when {{cssxref('font-weight')}} is `normal` and `14pt` (approximately `18.7px`) for `bold` text. Stating:
_Text that is larger and has wider character strokes is easier to read at lower contrast. Therefore, the contrast requirement for larger text is lower. This allows authors to use a wider range of color choices for large text, which is helpful for the design of pages, particularly titles._
While larger text does not require as great color contrast with its background as smaller text, increasing font size is not a panacea.
"Normal" print is usually considered 11.5pt to 12pt, equivalent to 16px on screen. While smaller font may be legible — a user can make out letters at \~70% accuracy — that is not readable. A 16px font size is generally readable for people with normal vision. Someone with 20/40 needs twice that, about a 31px font. This is why the WCAG guidelines require that users have the ability to zoom any text larger.
While a text displayed too small is hard to read, so is a text that is too large. For users with 20/20 vision, with a text size greater than approximately 96px, reading speed decreases. Also, when there is a large disparity between the smallest and largest font size on a page, the larger text will become less readable if users enlarge the smaller text on the page, as most browsers zoom all text as the user zooms.
In general, for accessibility purposes, the more contrast, the better. That changes with animation. "Safer" animation means images with less contrast, not more. For more on color contrast in animation, see [Three Flashes or Below Threshold Understanding SC 2.3.1](https://www.w3.org/TR/UNDERSTANDING-WCAG20/seizure-does-not-violate.html)
Also, note that icons need sufficient contrast for perception. See [WCAG 2.1 technique G207](https://www.w3.org/WAI/WCAG21/Techniques/general/G207)
### Luminance
It is the difference in the luminance of a color that enables us to see the contrast. Relative luminance is defined in WCAG as "the relative brightness of any point in a colorspace, normalized to 0 for darkest black and 1 for lightest white."
This statement is of course accurate, but may be confusing when used in reference to the RGB color space, which is an integer between 0 and 255. White has 100% relative luminance, black has 0% relative luminance (in most but not all literature). Interpreting for the W3C standard above, that would mean that white, normalized to 1, would have an RGB value of `rgb(255 255 255)` and black, normalized to 0, would have an RGB value of `rgb(0 0 0)`. Note that black and white can also be written as `rgb(100% 100% 100%)` and `rgb(0% 0% 0%)` respectively, which may be more intuitive.
So, where do these numbers of 0 to 255 come from? Historically, graphics engines stored the color channels as a single byte, which means a range of integers between 0 and 255.
The luminances of the primary colors are different. Yellow has a greater luminance than blue, for example. This was done by way of design, _to achieve white alignment of the monitor_, according to the NASA document, "[Luminance Contrast in Color Graphics](https://web.archive.org/web/20250216024807/https://colorusage.arc.nasa.gov/design_lum_1.php)"
A color contrast ratio is meaningless without its luminance component, and once luminance is established, the color contrast ratio can be established.
Where human perception is concerned, a difference in luminance matters more than a color difference. This is important, as luminance contrast enables the development of content that even those with color blindness can see. With this understanding, luminance may be manipulated so that colors that are difficult to see because of their low luminance could be made more legible by placing these colors against another with contrasting luminance. An interesting study by NASA on the color blue, for example, noted that this color, which has low luminance, can be made legible if _care was taken to achieve adequate luminance contrast_ (From the article, [Designing with blue](https://web.archive.org/web/20250216024807/https://colorusage.arc.nasa.gov/blue_2.php))
Calculations for relative luminance are not casual ones. Luckily, there are [online luminance and contrast checkers](https://www.siegemedia.com/contrast-ratio) available, and even instructions on how to [calculate relative luminance](https://w3c.github.io/wcag/guidelines/22/#dfn-relative-luminance).
## Perceiving color
Color is our perception of the narrow band of visible light, from red through yellow and green to blue. Our sensitivity to these various hues of color are not equal. The light sensitive cells in our [eyes](https://www.verywellhealth.com/eye-cones-5088699), called cones, are tuned to perceive some colors more than others. About 65% of cones are _most_ sensitive to a yellow/green, but also respond to red (we'll call these "red" cones). 30% are green sensitive, and only [5% are blue sensitive](https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0144891#sec001). While there are far fewer blue-sensitive cones than the other two types, these cones are very sensitive, which partially makes up for their smaller numbers.
Deep, pure blue is perceived differently than other colors as blue cones do not contribute to luminance and we have far fewer blue cones than red or green.

On the left is the central cone mosaic of standard vision, and on the right is that of someone with protanopia, a form of color vision deficiency, where they are missing the red cones. (Illustration by Mark Fairchild of RIT, [Wikimedia Commons](https://commons.wikimedia.org/wiki/File:ConeMosaics.jpg))
The red and the green cones join together to create luminance, which we can think of as lightness/darkness without regard to hue. Separately, the red, green, and blue cones allow for standard vision to perceive millions of colors. For accessibility, it's important to know that our brain processes luminance separately from color (hue and colorfulness).
Luminance provides for fine vision details, including differentiating edges and text. Hue and colorfulness carry a third of the detail of luminance. Image data compression takes advantage of this fact. As an example, [h.264 video codec](/en-US/docs/Web/Media/Guides/Formats/Video_codecs) samples color at a fourth of the resolution of the luminance.
For accessibility, this means that luminance contrast is critically important for text. Color, as in hue and colorfulness, is important for _distinguishing_ items such as different lines on a map or bars in a graph.
Another essential point to consider is the color or luminance that is surrounding a color. Colors appear differently depending on what is surrounding them. In the following image, both the yellow dots and the grey squares are the same sRGB color. Context-sensitive color perception makes them appear different; your brain's image processing adjusts the perception based on what it thinks is in shadow or not.

The yellow dots in this image are identical colors on your monitor, but they appear different due to context. (Image D.Lyon)
Our contrast, lightness, and color perception are affected by the context of the nearby colors and other features of a design or image. This makes predicting contrast challenging. It is not merely a mathematical ratio between two colors.
To summarize, color is as much about human physiology and perception in the brain as it is about measuring light from a computer screen. It's also important to understand that the ambient light environment affects the ability to perceive color and contrast. Light and its measurements are linear, but human vision and perception are not.
## Adaptation
Our eyes don't adapt equally, in the same way, going from light areas to dark ones and vice versa. This is due to the physiological ways our eyes are built. This affects the ability of a user to read text against a background. At least two kinds of adaptation take place: local adaptation and adaptation to an ambient environment.
Local adaptation occurs right on the "page" a reader is looking at. For example, if you have blue text within a gray "highlighted" area, your eyes will perceive that exact blue text with a gray highlight differently if it is in a black {{HTMLElement("div")}}, or a white one. This is called _local_ adaptation. This difference in the ability to perceive the text is affected even though the room's ambient lighting does not change.
The implication is that web developers who seek to improve the legibility of text against a background can take advantage of the principles of local adaptation.
Dark adaptation to low luminance is slow. When you come in from outside, where the sun is bright, and walk into a dark room, you are experiencing dark adaptation. It can take a few minutes to adjust to this.
Light adaptation is the reverse. Going from a dark room into bright sunlight is quicker but can also hurt.
The implication is that web developers who seek to improve the legibility of text in which the ambient conditions of a room have changed can take advantage of the `AmbientLightSensor` interface and the [`prefers-contrast`](/en-US/docs/Web/CSS/Reference/At-rules/@media/prefers-contrast) media query.
## Saturation
Saturation deserves a special mention in discussions about color ("hues") and accessibility. Generally speaking, most focus is on luminance when attempting to ensure enough contrast between text and its background or evaluating the possibility of inducing seizures in those sensitive to photosensitive seizures. One aspect of color ("hues"), independent of luminance, deserves special attention as it applies to accessibility: the concept of saturation. This is due to its ability to cause seizures in those susceptible to photosensitive seizures, regardless of color's luminance. As discussed in [the particular case of red](#the_special_case_of_red), [Harding et al. 2005](https://onlinelibrary.wiley.com/doi/pdf/10.1111/j.1528-1167.2005.31305.x) noted that, _irrespective of luminance, a transition to or from a saturated red is also considered a risk_.
Saturation is sometimes described as the "purity" or "intensity" of a color. Although these are good definitions for "pigments" in an artist's paint set, they are not as accurate as color definitions from a computer screen.
When it comes to color on a monitor, saturated colors are of a particular wavelength. While the definition of saturation for each color space may differ, saturation is readily measured. The key is to know which color space you are working in and be ready to convert it if necessary.
The color spaces most frequently considered when discussing photosensitivity are the RGB, HSL, and HSV, also known as HSB, color spaces. The HSV color space, which stands for _hue_, _saturation_, and _value_, and the synonym HSB, which stands for _hue_, _saturation_, and _brightness_, are represented in CSS as {{cssxref("color_value/hwb")}} for _hue_, _whiteness_, and _blackness_.
It's important to know what color space you're working with. For example, saturated colors have a lightness of `0.5` in HSL, while in HWB, they have a value `1`. Saturation in the RGB color space is usually indicated by an RGB value of `255` or `100%` for the color in question. For example, a saturated red of hex value `#ff0000` has an RGB value of `rgb(255 0 0)` and an HSL value of `hsl(0 100% 50%)`. A different saturated red with a hex value of `#ff3300` has an RGB value of `rgb(255 51 0)` and an HSL value of `hsl(12 100% 50%)`. Both are "saturated" reds. They are two different "hues" but are both considered to be a saturated color.
Saturation is not brightness. Brightness refers to how much white or black is mixed in with a color. One can decrease saturation by adding white, black, or gray to the color; to take the example further, brightness can be increased by adding white, reducing saturation. A typical example is to add white to red to get the color pink. Pink is considered a desaturated red.
### Saturation and luminance
There is a loss of saturation at the extremes of luminance and the extremes of black and white. In NASA's [effect of luminance on saturation](https://web.archive.org/web/20250216024807/https://colorusage.arc.nasa.gov/design_lum_1.php), they point out that there is a loss of saturation at low luminances, and also, "…the loss of saturation at high luminances–the colors converge on white."
## Color combinations
Contrast alone is not enough when it comes to accessibility considerations. In the case of animation, certain color combinations are more likely to cause photosensitive seizures to those who are susceptible to them than others. For example, alternating flashes between red and blue is more problematic than alternating flashes between green and blue. It has been theorized that this is because the "red" sensitive cones of our eyes, which tend to cluster around the fovea (near the center), are physically located at a different location than the "blue" sensitive cones of our eyes, which are located away from the fovea and towards the rims. The electrical signals from the eye to the brain have much to resolve between them as the information is processed in our brains.
Some colors more likely to [cause epileptic seizures](https://www.epilepsy.com/sites/default/files/2022-10/Epilepsia_2022_fisher_visually_sensitive_seizures.pdf). Complexities underlying brain dynamics can be modulated by some color combinations more than the others. For example, red-blue flickering stimulus causes larger cortical excitation than red-green or blue-green stimulus.
Certain color combinations can be very problematic on a computer monitor or mobile device, and some color combinations can interfere with some impairments. The combination of red/blue is one such example.
- Never rely on hue alone for differentiating details. Adequate luminance contrast is required.
- The green in a monitor makes up the vast majority of luminance (light), so it will usually be a significant part of the lighter colors.
### Working with blue
Some people cannot differentiate between all colors. Some colors, such as pure blue, are low in luminance. Colors that are low in luminance should be the darker of contrasting colors. Blue is also very low in resolution. There are far fewer blue cones, and they are scattered in our peripheral vision and not present in our central vision. The human eye sees blue at a lower resolution than green and red.
This leads to some blue color use guidelines:
- Pure blues should typically be the darkest of two colors.
- When using blue as the lighter of the two colors, add green to increase contrast and improve readability.
The nature of blue light causes it to focus at a different location on the retina than red, so a pure red and a pure blue color that are immediately adjacent and touching may "shimmer" when next to each other.
## The special case of red
Not all colors ("hue") are processed similarly by our brains. Human physiology and psychology are affected by the color red, generally speaking, in ways different from that of other colors. We respond physiologically as well as psychologically to colors. For example, it has been demonstrated that [some colors are more likely to cause epileptic fits than others](https://www.sciencedaily.com/releases/2009/09/090925092858.htm). Some devices offer a ["grayscale" setting as an accessibility option](https://ask.metafilter.com/312049/What-is-the-grayscale-setting-for-in-accessibility-options)" which can help people who are photo-sensitive. To mimic the grayscale setting, use the CSS {{cssxref("filter")}} property with a {{cssxref("filter-function/grayscale")}} or {{cssxref("filter-function/saturate")}} {{cssxref("filter-function")}}.
### Saturated red
"Saturated Red" is a special, dangerous case, and there are special tests for it.
The concept of color saturation is a difficult one to understand when only looking at numbers and terminology, so consider looking at the image below to illustrate the concept of saturation in a color:
![Red Saturation from Wikimedia Commons svg saved as png Attribution: Datumizer [CC0]](320px-red_saturations.svg.png)
The same "color" proceeds from least saturated on the left-hand side to most saturated on the right-hand side.
_More than one "red" color may be considered a "saturated" red._ For example, the color `#990000` at `hsl(0 100% 30%)` is fully saturated but is less bright than the colors described above. Similarly, the color `#8b0000` also has a saturation of 100%.
Not all saturated reds may be represented well in the RGB spectrum or other spectrums commonly used in web development. According to Wikipedia's page on "Shades of Red", the color "Carmine" is a saturated red which, in its pigment form, mostly contains red light with wavelengths longer than 600nm; the article makes the special note that "Carmine" is close to the extreme spectrum. This places it far beyond standard gamuts (RGB and CMYK), and its given RGB value is a poor approximation only."
### Saturated red flashing
In addition to a red environment affecting the cognitive function of those with traumatic brain injury, color in the red spectrum wavelength requires special attention and tests.
Gregg Vanderheiden, when testing the _Photosensitive epilepsy analysis tool_, noted seizure rates were much higher than expected. They found that we are much more sensitive to saturated red flashing. (See the video, [The Photosensitive epilepsy analysis tool](https://www.pbs.org/video/university-place-the-photosensitive-epilepsy-analysis-tool-ep-429/).)
### Flashing and seizures
Continuous flashing brighter/darker at rates higher than three flashes per second has been shown to induce photic seizures in some people. It has also been found that specific, very regular, high-contrast patterns, such as parallel white and black stripes, can also induce seizures.
[Harding et al. 2005](https://onlinelibrary.wiley.com/doi/pdf/10.1111/j.1528-1167.2005.31305.x) present several fundamental guidelines:
1. Single, double, or triple flashes in one second are acceptable, but a sequence of flashes is not recommended when more than three flashes happen within one second.
2. When displaying light and dark stripes, the pattern should display no more than five light–dark pairs of stripes, if the stripes change direction, oscillate, flash, or reverse in contrast or eight light–dark pairs of stripes, if the pattern is unchanging or continuously and smoothly drifting in one direction.
For more recommendations, see the paper [Photic- and Pattern-induced Seizures: Expert Consensus of the Epilepsy Foundation of America](https://onlinelibrary.wiley.com/doi/epdf/10.1111/j.1528-1167.2005.31405.x).
## Psychophysical aspects of color
Color as in hues and saturation can affect our mood, and enhance — or de-enhance — our interactive experiences.
### Examples of color's effect beyond vision
- **Color can be culturally dependent:** [A Cross-Cultural Study of the Affective Meanings of Color](https://journals.sagepub.com/doi/10.1177/002202217300400201)
- **Color affects our emotions:** [Color and emotion: effects of hue, saturation, and brightness](https://pubmed.ncbi.nlm.nih.gov/28612080/)
- **Higher contrasts can also have a positive affect on our emotions:** [Emotion Variation from Controlling Contrast of Visual Contents through EEG-Based Deep Emotion Recognition](https://pubmed.ncbi.nlm.nih.gov/32823741/)
- **Some colors can affect our perception of time:** [Color and time perception: Evidence for temporal overestimation of blue stimuli](https://pubmed.ncbi.nlm.nih.gov/29374198/)
- **Blue also has a significant effect on brightness and glare:** [Blue and glare & brightness](https://pubmed.ncbi.nlm.nih.gov/31288107/)
- **Red tinted glasses can provide increased happiness or joy:** [Looking Through "Rose-Tinted" Glasses: The Influence of Tint on Visual Affective Processing](https://pubmed.ncbi.nlm.nih.gov/31244627/)
- **Red is well known to have significant effects on our behavior:** [How the Color Red Influences Our Behavior](https://www.scientificamerican.com/article/how-the-color-red-influences-our-behavior/), Scientific American, S. Martinez-Conde, Stephen L. Macknik
- **Red Environment:** Studies have shown that for those who suffer Traumatic Brain Injury, [cognitive function is reduced in a red environment](https://pubmed.ncbi.nlm.nih.gov/20649469/).
## See also
- [Accessibility](/en-US/docs/Web/Accessibility)
- [Accessibility learning path](/en-US/docs/Learn_web_development/Core/Accessibility)
- CSS {{cssxref("color")}} property
- CSS {{cssxref("<color>")}} data type
- [Web accessibility for seizures and physical reactions](/en-US/docs/Web/Accessibility/Guides/Seizure_disorders)
- [How the Color Red Influences Our Behavior](https://www.scientificamerican.com/article/how-the-color-red-influences-our-behavior/) Scientific American By Susana Martinez-Conde, Stephen L. Macknik on November 1, 2014
- [Red Desaturation](https://www.smartoptometry.app/red-desaturation/) The human eye is so sensitively "tuned" to red, that ophthalmologists set up a test using it, assessing the integrity of the optic nerve.
- [Photic- and pattern-induced seizures: expert consensus of the Epilepsy Foundation of America Working Group](https://onlinelibrary.wiley.com/doi/pdf/10.1111/j.1528-1167.2005.31305.x)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.