accessibility.md 4.51 KB
Newer Older
Mark Otto's avatar
Mark Otto committed
1
---
Mark Otto's avatar
Mark Otto committed
2
layout: docs
Mark Otto's avatar
Mark Otto committed
3
title: Accessibility
4
description: A brief overview of Bootstrap's features and limitations for the creation of accessible content.
5
group: getting-started
6
toc: true
Mark Otto's avatar
Mark Otto committed
7
8
---

9
Bootstrap provides an easy-to-use framework of ready-made styles, layout tools, and interactive components, allowing developers to create websites and applications that are visually appealing, functionally rich, and accessible out of the box.
Mark Otto's avatar
Mark Otto committed
10

11
## Overview and Limitations
Mark Otto's avatar
Mark Otto committed
12

13
The overall accessibility of any project built with Bootstrap depends in large part on the author's markup, additional styling, and scripting they've included. However, provided that these have been implemented correctly, it should be perfectly possible to create websites and applications with Bootstrap that fulfill [<abbr title="Web Content Accessibility Guidelines">WCAG</abbr> 2.0](https://www.w3.org/TR/WCAG20/) (A/AA/AAA), [Section 508](https://www.section508.gov/) and similar accessibility standards and requirements.
Mark Otto's avatar
Mark Otto committed
14

15
### Structural markup
Mark Otto's avatar
Mark Otto committed
16

17
Bootstrap's styling and layout can be applied to a wide range of markup structures. This documentation aims to provide developers with best practice examples to demonstrate the use of Bootstrap itself and illustrate appropriate semantic markup, including ways in which potential accessibility concerns can be addressed.
Mark Otto's avatar
Mark Otto committed
18

19
### Interactive components
Mark Otto's avatar
Mark Otto committed
20

21
Bootstrap's interactive components—such as modal dialogs, dropdown menus and custom tooltips—are designed to work for touch, mouse and keyboard users. Through the use of relevant [<abbr title="Web Accessibility Initiative">WAI</abbr>-<abbr title="Accessible Rich Internet Applications">ARIA</abbr>](https://www.w3.org/WAI/standards-guidelines/aria/) roles and attributes, these components should also be understandable and operable using assistive technologies (such as screen readers).
Mark Otto's avatar
Mark Otto committed
22

23
Because Bootstrap's components are purposely designed to be fairly generic, authors may need to include further <abbr title="Accessible Rich Internet Applications">ARIA</abbr> roles and attributes, as well as JavaScript behavior, to more accurately convey the precise nature and functionality of their component. This is usually noted in the documentation.
Mark Otto's avatar
Mark Otto committed
24

25
### Color contrast
26

27
Most colors that currently make up Bootstrap's default palette—used throughout the framework for things such as button variations, alert variations, form validation indicators—lead to *insufficient* color contrast (below the recommended [WCAG 2.0 color contrast ratio of 4.5:1](https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html)) when used against a light background. Authors will need to manually modify/extend these default colors to ensure adequate color contrast ratios.
28

29
30
31
### Visually hidden content

Content which should be visually hidden, but remain accessible to assistive technologies such as screen readers, can be styled using the `.sr-only` class. This can be useful in situations where additional visual information or cues (such as meaning denoted through the use of color) need to also be conveyed to non-visual users.
Mark Otto's avatar
Mark Otto committed
32

XhmikosR's avatar
XhmikosR committed
33
{{< highlight html >}}
34
<p class="text-danger">
汪磊's avatar
汪磊 committed
35
  <span class="sr-only">Danger: </span>
36
37
  This action is not reversible
</p>
XhmikosR's avatar
XhmikosR committed
38
{{< /highlight >}}
Mark Otto's avatar
Mark Otto committed
39

40
For visually hidden interactive controls, such as traditional "skip" links, use the `.sr-only-focusable` class. This will ensure that the control becomes visible once focused (for sighted keyboard users). **Watch out, since Bootstrap 5 the `.sr-only-focusable` class may not be used in combination with the `.sr-only` class.**
Mark Otto's avatar
Mark Otto committed
41

XhmikosR's avatar
XhmikosR committed
42
{{< highlight html >}}
43
<a class="sr-only-focusable" href="#content">Skip to main content</a>
XhmikosR's avatar
XhmikosR committed
44
{{< /highlight >}}
Mark Otto's avatar
Mark Otto committed
45

46
47
### Reduced motion

48
Bootstrap includes support for the [`prefers-reduced-motion` media feature](https://drafts.csswg.org/mediaqueries-5/#prefers-reduced-motion). In browsers/environments that allow the user to specify their preference for reduced motion, most CSS transition effects in Bootstrap (for instance, when a modal dialog is opened or closed, or the sliding animation in carousels) will be disabled.
49

Mark Otto's avatar
Mark Otto committed
50
## Additional resources
Mark Otto's avatar
Mark Otto committed
51

52
- [Web Content Accessibility Guidelines (WCAG) 2.0](https://www.w3.org/TR/WCAG20/)
XhmikosR's avatar
XhmikosR committed
53
- [The A11Y Project](https://a11yproject.com/)
54
- [MDN accessibility documentation](https://developer.mozilla.org/en-US/docs/Web/Accessibility)
55
- [Tenon.io Accessibility Checker](https://tenon.io/)
56
- [Color Contrast Analyser (CCA)](https://developer.paciellogroup.com/resources/contrastanalyser/)
57
- ["HTML Codesniffer" bookmarklet for identifying accessibility issues](https://github.com/squizlabs/HTML_CodeSniffer)