Creating Buttons using role=button
Authoring Practice Design Patten for button
Note: When using HTML use the <button>
element. It is recommended that authors not re-purpose other elements to create buttons.
Button Examples
The following examples are composed by a native <button>
element, a <div>
functioning as a native button, and a <span>
element that functions as a toggle button.
Type | Technique | Button | Accessibility Feature |
---|---|---|---|
Push button | div element with text |
Print Page
|
|
Toggle button | div element with text |
Mute |
|
Push button | tabindex="0" element |
Show alert |
|
Non compliant | a element with href="#" |
Show alert |
|
Keyboard Support
Key | Function |
---|---|
Space or enter | Activate or toggle button |
ARIA Roles, Properties and States
Role | Property/State | Component | Usage |
---|---|---|---|
button | span or div |
|
|
aria-pressed | span |
|
Source Code
HTML Code
HTML source code is generated by scripting using ID references.