
Techniques for Accessible Web Pages 15
neutral <div>container element, attaching a JavaScript handler for click events, and embedding an image
of the desired icon. However, if no additional measures are taken, this kind of implementation provides
poor accessibility. Firstly, the element is not displayed as expected, if loading of graphics has been
deactivated in the browser. Secondly, the button cannot be focused and triggered using the keyboard.
Finally, screen readers are not informed about the meaning of the element. This has the consequence that
the corresponding text label, if available, is interpreted and output by the screen reader as if it was a mere
piece of text, so that a blind user is not told about the button functionality. In case that no textual label
is provided, the embedded image might be interpreted as decorative, causing the button to be completely
ignored by the screen reader. Even if the user infers the meaning from the prompt of a label and selects
the button by means of the screen reader’s navigation facilities, pressing Enter or Space might have no
effect, since the AT is not supplied with definitive information about how to interact with the element or
where exactly to place a simulated mouse click. Using the <button>element, by contrast, creates an object
which is appropriately displayed by the browser even if graphics are not loaded, can receive keyboard
focus, dispatches click events upon presses of the Enter or the Space key, and is well understood by ATs.
The scenario just described applies analogously for any other object intended to interact with the user.
A highly problematic issue is the non-standard implementation of a checkbox or a radio button, since
in both cases, the associated text is not included as a descendant element or as an attribute, but rather
as a separate element placed next to it. Therefore, a checkbox or radio button created by means of the
<div>element will contain only graphical information by default, meaning that the interactive object itself
might not be considered by screen readers. As a consequence, the information about its state, that is,
whether it has been checked or not, is not reported to a blind user. Moreover, if the user navigates to the
associated text, pressing Enter or Space might cause the screen reader to perform a mouse click on the
label but not on the checkbox or radio button itself, so that its state is not changed.
Another example concerns the formatting of text fragments as headings [Pickering 2016, page 79].
HTML specifies the elements <h1>to <h6>for the purpose of declaring headings at six distinct hierarchical
levels. Applying this technique ensures that browsers display the respective text at appropriate font sizes,
depending on the level, the size of the screen, and the visual preferences configured by the user. Screen
readers present the text fragment as a heading of the specified level, for instance: “Heading level 2,
Introduction”. In addition, screen reader users can benefit from the feature of navigating directly to the
next or previous heading, to quickly obtain an overview of a web document or to find a particular section.
If, by contrast, the respective text is only visually highlighted, for instance using Cascading Style Sheets
(CSS), all the advantages just mentioned are not available. Conversely, the use of heading elements as a
means of visual formatting for text fragments which are not intended to act as headings leads to screen
readers erroneously announcing the piece of text as a heading, and the facility of navigating by headings
might set the accessibility focus of the AT to unintended locations.
Although most screen readers offer a mode for browsing web pages by keyboard, independent of the
operating system’s navigation, it is recommended to ensure that every user input control can receive
keyboard focus by means of the Tab key [Pickering 2016, pages 61–63]. All HTML elements explicitly
designed for user interaction, such as <a>,<input>,<button>,<select>, and <details>, do so by default.
If a different element is used, it can be declared focusable by attaching the tabindex attribute to it. The
attribute’s value is an integer ≥ −1and determines if and in which order the elements are focused when
pressing the Tab key (known as tab order). A positive number indicates elements which should be focused
first, in that order. Elements with a tabindex value of 0are focused afterwards in the order they appear in
the source code. Elements with a tabindex value of -1 are not included within the tab order, and can only
be focused programmatically.
Furthermore, every element should provide an accessible name, that is, an associated title which can
be read by ATs [Pickering 2016, page 39]. In the case of a cancel button, for example, this would typically
be the string “Cancel”. When text is embedded within an element, it is taken to be the element’s name
in most cases. If no associated text content is present, the accessible name needs to be explicitly defined
by the author of the web content, for instance using ARIA properties, as described in Subsection 2.4.2.