Accessibility is often treated as a final stage of web development. The website is designed and built, and accessibility is then assessed before it is released.
The difficulty with this approach is that many accessibility problems originate in decisions made considerably earlier in the development process. The structure of a page, the choice of HTML elements and the way in which an application handles user interaction all have implications for accessibility.
People use websites with different devices, input methods and assistive technologies. An interface should not depend upon a particular method of interaction where an equivalent, accessible alternative can reasonably be provided.
Semantic HTML
Browsers already provide a considerable amount of functionality through native HTML elements. Much of this can be lost when an interface is constructed predominantly from generic elements.
Consider the difference between a button and a link. A button performs an action, whereas a link navigates to a resource. Although the two can be styled to look identical, browsers and assistive technologies interpret them differently.
A native button is keyboard-focusable by default (unless disabled) and can be activated using the Enter or Space key. Recreating a button using a generic element requires the developer to implement its semantics, focus behaviour and keyboard interaction separately.
The same principle applies to the structure of a document. Headings should describe the hierarchy of its content rather than be selected according to their default font size. Form controls should have associated labels, and lists should be represented as lists.
There are circumstances in which a bespoke component is necessary, particularly in more complex web applications. However, the browser's existing functionality should generally be the starting point. ARIA can supplement native semantics where necessary, but adding an ARIA role does not implement the corresponding interaction behaviour.
Keyboard navigation and focus
Keyboard navigation is an important part of developing and testing an interface, particularly one containing interactive components such as menus and modal dialogues.
A relatively straightforward test is to navigate through a page using Tab and Shift+Tab. The order in which elements receive focus should be logical, and it should be possible to identify the currently focused element.
More complex interactions require additional consideration. When a modal dialogue opens, focus should move to an appropriate element within it. Whilst the dialogue is open, keyboard focus should remain within it. Closing the dialogue should normally return focus to the control that opened it, provided that control still exists and remains appropriate.
Removing the browser's default focus outline without providing a visible alternative is a common example of a visual design decision adversely affecting accessibility. There is no particular requirement to retain the browser's default appearance, but the replacement must allow the user to determine where focus is.
Forms and validation
Forms are an area in which accessibility problems can prevent a user from completing the intended task altogether.
Each input requires an accessible name, ordinarily provided by a visible and programmatically associated label. Placeholder text should not be relied upon as a replacement for a label, not least because it disappears when the user enters a value.
Where a field has specific requirements, these should be communicated before the form is submitted. Password requirements are a good example.
Validation errors should identify the affected field and explain the nature of the problem. Changing the border colour of an input to red might provide a useful visual indication, but it does not explain why the value is invalid.
An error message can be associated with its corresponding input using aria-describedby, and aria-invalid can indicate that the input contains an invalid value. In longer forms, an error summary with links to the affected fields can also help users locate and correct problems.
It is worth considering the entire process of submitting a form, including what happens when a request fails and whether the values already entered by the user are preserved.
Visual design and responsive layouts
Colour is useful for communicating information, but it should not be the sole means of doing so. For example, a status indicator consisting of a green or red circle can be accompanied by a textual description of the status.
Contrast is another consideration. Text that appears sufficiently legible on a designer's display may be considerably more difficult to read under different conditions. Both text and relevant graphical elements, including indicators necessary to identify controls, require appropriate contrast.
Responsive design should also account for users enlarging text or zooming their browser, rather than considering only the dimensions of different devices.
A page that works well on a mobile device at its default text size may still have problems when the text is enlarged. Fixed-height containers, navigation items and form controls are particularly worth testing. Content should ordinarily reflow without losing information or functionality, although some content, such as complex data tables, may require two-dimensional scrolling.
Accessibility and resilience
There is considerable overlap between accessibility and the resilience of a web interface.
Where an image conveys information, its alternative text should communicate the relevant information or purpose. Purely decorative images should ordinarily have an empty alternative text attribute so that they can be ignored by assistive technologies.
Applications that update content without navigating to another page also need to consider how those updates are communicated. For example, when a form is saved asynchronously, an appropriate status region can communicate the outcome to a screen reader without moving the user's focus unnecessarily.
Loading, empty and error states warrant the same consideration as the successful state of an application. A user should be able to understand whether a request is still in progress, whether it has failed and what action, if any, is required.
Progressive enhancement is useful in this context. Where practical, content and navigation can be delivered using the capabilities of the browser before additional behaviour is introduced through JavaScript.
This does not mean that every web application must operate without JavaScript. There are applications for which JavaScript is fundamental to their functionality. The distinction is whether a dependency is necessary for the functionality being provided or whether it has introduced an avoidable point of failure.
Testing accessibility
Automated accessibility testing is useful for identifying certain classes of problem, including missing accessible names, some contrast failures and incorrect use of ARIA attributes.
However, it cannot establish whether an interface is accessible in its entirety. A tool might determine that an image has an alternative text attribute without being able to establish whether the description is appropriate in the context of the page.
Manual testing should therefore form part of the development process. This includes navigating by keyboard, testing with a screen reader, enlarging text and examining the behaviour of the interface at different viewport sizes. Testing with people who use assistive technologies in their everyday lives can reveal problems that neither automated checks nor developer testing will identify.
The Web Content Accessibility Guidelines (WCAG) provide a framework against which accessibility can be assessed. Automated testing alone is not sufficient to demonstrate conformance with those guidelines.
Accessibility in the development process
One of the advantages of a component-based application is that improvements to a shared component can benefit every part of the application in which it is used. The reverse is also true: a problem with keyboard navigation in a shared component may be present throughout the application.
It is therefore worth considering accessibility when developing the components themselves, as well as when testing the pages and workflows in which they are used.
Many of the decisions discussed in this article are relatively inexpensive to make during development. Retrofitting them across an established application can be considerably more involved, particularly where the problems originate in its underlying structure.
By treating accessibility as a consideration throughout design, implementation and testing, rather than as a separate exercise before release, we can develop interfaces that are usable in a wider range of circumstances and are generally easier to maintain.