Buttons
Introduction
In some cases, developers build custom versions of native HTML controls because they cannot achieve the exact look and feel or behavior they desire with a native control. Wherever possible, it is strongly recommended that native HTML controls be used over custom controls, as their accessibility support is much more robust.
WCAG criteria
- 2.1.1 Keyboard (level A)
- 2.4.4 Link Purpose (In Context) (level A)
- 4.1.2 Name, Role, Value (level A)
Scope of the issue
In the case of C3, the buttons throughout the application are only styled to look like buttons. The C3 markup for a submit button is as follows:
<input type="image" name="btnSubmit" tabindex="12" src="/button_submit.gif" border="0">
There are a few accessibility issues with this:
- It only has a visual “submit” label. Non-sighted users will not know the purpose of this button.
- It is identified in the code as an image, not a button.
- It has a positive tab index. (See Inconsistency for more info on this.)
- In some cases, it may not be usable with a keyboard because:
- it is not focusable
- it does not respond to the expected keys for activating a button
Fixing the issue
It is recommended that the image type buttons be replaced with the native HTML <button>
element, like so:
<button type="submit">Submit</button>