I've always wondered if using a <button>
tag purely to link a page bad for Web Content Accessibility Guidelines (WCAG)?
When is it an improper and proper use of the <button>
tag?
Thanks in advance!
I've always wondered if using a <button>
tag purely to link a page bad for Web Content Accessibility Guidelines (WCAG)?
When is it an improper and proper use of the <button>
tag?
Thanks in advance!
What's the most common result of clicking something on a website? Moving to a new URL, like you would clicking a link (Anchor) element.The
<button>
element, by itself, can't do that.Button is a Form Element...
For complete article about differences of Anchor and Button:
WCAG 2.0 guideline 4.1.2 Name, Role, Value starts with:
For all user interface components (including but not limited to: form elements, links and components generated by scripts), the name and role can be programmatically determined […]
The mentioned role is defined by this:
text or number by which software can identify the function of a component within Web content
So you would have to convey (for software) that your button
element has the role of a hyperlink instead of a button.
In HTML5, the button
element can have the WAI-ARIA link
role. So using this role would be one way (maybe even the only way) to conform to 4.1.2 in your case, assuming that the software of your visitors supports WAI-ARIA.