Keyboard exercise
Test your knowledge Heading link
This exercise page has WCAG violations that can be best be detected via keyboard testing. Using the information you learned in the How to test manually with a keyboard section, identify all WCAG violations below using your keyboard, and fix them if you can. You’ll want to interact with the page’s focusable elements and enter data whenever possible.
An issue with a form-related element
Buttons must have discernible text (WCAG SC 4.1.2)
You probably spotted this one right away. The button doesn't have any text in it, which violates WCAG Success Criteria 4.1.2.
Adding text to the button element will fix this. Alternately, adding an aria-label attribute to the button will also suffice, but remember that native HTML solutions are preferred according to best practices.
Click on the button to submit your information.
Similar to above, but not in <form> form
Links must have discernible text (WCAG SC 2.4.4)
There's an anchor tag below containing a link, but it doesn't have any text in it. This situation is similar to the button issue above, but this one violates WCAG Success Criteria 2.4.4, which requires text that describes what the link does or where it goes.
It's also an issue for sighted users, who can't even see the link. Note that you can still tab to the link (it still receives keyboard focus) and activate it by pressing the enter key.
It is possible to commit no mistakes and still lose. That is not a weakness. That is life.
—Captain Jean-Luc Picard (Stardate 42923.4)
Nav menus and keyboards
All functionality must be keyboard accessible (WCAG SC 2.1.1)
This is a violation of WCAG Success Criterion 2.1.1, which states that everything interactive on the page must be operable via keyboard input. If you can do something with a mouse, you must be able to do it with a keyboard.
In the navigation menu example below, the submenu items can be seen upon mouseover but are not present when using a keyboard. You may recall the usable keys for manual page navigation, listed in the "How to test" section for keyboards; none of these inputs allows you to view the submenu dropdown, which is especially crucial in real-life cases like this because a significant amount of content would be hidden from the site visitor. To fix this, you must allow the site visitor to see the dropdown submenus.
Expected behavior: when a top-level menu item is in focus (e.g. the "Cruisers" item), you should be able to view its submenu (if applicable) by pressing the enter key.
This is an example of a navigation menu.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In pellentesque neque dolor, non finibus purus consequat et. Ut quis purus mauris. Nulla eu consequat velit, consectetur faucibus erat. Nulla eget sodales erat. Morbi at semper mauris. Vivamus feugiat dolor vel lectus finibus, at consectetur sem lobortis. Aliquam velit magna, feugiat et eros in, varius eleifend leo. Mauris facilisis nisi vel ante pharetra convallis. Donec laoreet iaculis nunc vel rhoncus. Duis congue aliquet ante, finibus fringilla enim cursus nec.
Context gives meaning to something
Meaningful error messages (WCAG SC 3.3.3)
For error messages to be meaningful, you must include instructions that explain to the user how to correct the error. In this example, if you start typing a phone number in the field, the input returns an error that says "Wrong. Try again." So what's wrong with what you typed in the field? Is it too long or too short? What did you do wrong? This cryptic error message isn't at all helpful for the person using this form.
Expected behavior: generated dialogue informing the user of any field restrictions and what they must do to meet form submission requirements.
This one might require focus
Links must have visual focus indicators
If a link receives focus from a keyboard (e.g. via the TAB key), the page must render a visible border around the object indicating the location to the user. In the example below, the text "spaghetti recipe" links to another location but does not show when it is in focus. This is a violation of WCAG SC 2.4.7, which can only be resolved with the addition of a visual focus indicator.
When it comes to cooking, you'll find food tastes better if made from scratch. For example, look at this spaghetti recipe, which instructs you how to cook this delish dish from scratch. It doesn't list meatballs as an ingredient, but oh well...nobody's perfect.
Buttons and expectations
Links must have visual focus indicators (WCAG SC 2.4.7)
This example can also be found on the Screen Reader exercise page. The expectations for a keyboard-only use case are different, but the accessibility impediment is just as serious since the component doesn't communicate essential information to the user. These Accordion buttons don't show a visual outline when they receive focus, so they are inaccessible to users who rely on a keyboard as a sole means of input. When receiving focus from a keyboard (e.g. via Tab key), all interactive elements must display a visual focus indicator.
Content for Section 1
Content for Section 2