= Accessibility (a11y)
Decidim, just like the World Wide Web, is built for everyone regardless of individual abilities or disabilities, and for any software and hardware capable of connecting to the internet. Developing services in an accessible way ensures that the services can reach to audiences as wide as possible which is the most important principle of democracy.
Decidim follows the latest version of the Web Content Accessibility Guidelines (WCAG) but we have seen that these guidelines may be quite broad, complex, and hard to understand for many developers. The purpose of this guide is to provide some simple tips on how to follow the accessibility guidelines when developing the Decidim user interface.
== Is it necessary?
Most websites built on Decidim are under different regulations that require these services to follow accessibility guidelines. Therefore, following the guidelines and making your Decidim-based websites accessible are often requirements, not suggestions. Any core contributions have to follow the accessibility guidelines and individual services need to follow them most of the time.
Note that while we try to make Decidim as accessible as possible, implementers can easily break accessibility e.g. by changing the colors or customizing the Decidim user interface with their Decidim instances. It is therefore important for everyone working with Decidim to have at least a basic level of understanding regarding accessibility, even when you are not a core contributor.
== General advice
Accessibility of websites is based on the https://www.w3.org/WAI/standards-guidelines/wcag/[Web Content Accessibility Guidelines (WCAG)]. Although they are extensive, you will bump into them when involved in different accessibility evaluations, as the evaluators are following these guidelines.
These guidelines are constantly evolving and new versions can come out that may require changes in already implemented functionality. Some of the violations can be noticed automatically but others violations require a real person to test the website with the common assistive technologies used for browsing the internet (see the "Testing" section below).
Accessibility is not only technical. The end results have to be well tested and audited by unbiased 3rd parties to ensure the best outcome. With the core development we aim to consider the following criteria for creating accessible user interfaces:
. Technical accessibility using https://dequeuniversity.com/rules/axe/latest[Axe]
. Perceived accessibility using latest version of https://www.w3.org/WAI/standards-guidelines/wcag/[the WCAG recommendations]
. Cognitive accessibility using https://www.w3.org/WAI/WCAG2/supplemental/#cognitiveaccessibilityguidance[the WCAG Cognitive Accessibility Guidance] and the guide for https://www.w3.org/TR/coga-usable/[Making Content Usable for People with Cognitive and Learning Disabilities]
=== Common mistakes
This section contains some common mistakes that developers tend to do regarding accessibility. These do not cover all of the things you need to consider regarding accessibility but we add common issues in this list as we notice them.
==== Illogical heading order
Every page should have a logical heading order when using the `
`, `
`, `
`, `
`, `
` and `
` heading elements. This means that you cannot add e.g. a `
` if the previous heading was `
` before the sub-level heading element appears in the document. `
` should be followed by `
`. Under the `
`, you can add `
`.
Few other general bits of advice regarding the headings on the page:
* Every page should have only one `
` element on them to indicate the main topic of that page
* The `
` of the page should match the first part of that page's `` element, or at least be very close to that
* Sub-level headings should always be related to each other, i.e. the `
` level heading is related to the `
` heading that preceded it
==== Unique H1 on every page
Every page should have a unique H1 heading on it. For example, if you have a user profile split into multiple "tabs", each of these "tabs" should have a unique `
` heading instead of all of the "tabs" having e.g. the same user name as their `
`. Having the same `
` for multiple pages is problematic for accessibility because screen reader users often use the `
` to identify which section of the site they are "looking" at. If you have the same `
` on all related pages, it makes identifying those pages confusing for the screen reader users.
==== Heading on important sections
Imagine going to a bookstore and finding an interesting book cover in the section of books you are interested in. You pick up the book and open it. What is the first thing you generally do after you read through the back cover? Many people open the table of contents of the book and browse it through to get a sense of the contents of the book without reading the whole book.
This situation is comparable to screen reader users "glancing" through the web page contents. Screen reader users often "glance" through the page by looking at all the headings on the page as well as browsing through the links on the page. It is therefore highly important that each important section of the page has a heading to make it easier to understand what important sections are on the page just by browsing through its headings.
==== Color contrast
When creating user interfaces or modifying the colors, always make sure that you are not breaking accessibility with your changes. You can use the http://webaim.org/resources/contrastchecker/[Color contrast checker] to ensure that your colors have enough contrast against the background color where they are displayed at.
It is also important that the links have enough contrast difference with the surrounding text where the links appear. Another thing to note is to provide enough contrast difference for the interactive elements, such as links and buttons, between their default states and their hover or focus states.
To learn more, refer to:
https://www.w3.org/TR/WCAG21/#use-of-color
https://www.w3.org/WAI/WCAG21/Techniques/general/G183
==== Links and buttons
Many developers tend to use the `` element to indicate a clickable UI element on the page but using the `` element is not always correct. The anchor elements (i.e. links) are meant to link to different pages or to anchor positions within the page. If the element is supposed to e.g. open some hidden item on that page, you should use the `