alphagov / govuk_elements

❗️GOV.UK Elements is deprecated, and will only receive major bug fixes and security patches.
https://govuk-elements.herokuapp.com/
MIT License
227 stars 90 forks source link

Role attribute on native semantic elements <a> #539

Closed trevorsaint closed 7 years ago

trevorsaint commented 7 years ago

Is the role attribute on an anchor tag correct usage of the role attribute?

Adding the role attribute to a span tag perhaps, but not an anchor tag.

Passing this through tenon.io comes back a fail.

How would you expect it to work?

I don't think it is required on anchor tags.

We could perhaps use a data attribute of button and target this with the javascript shim to make it act as a button rather than targetting the role attribute.

<a class="button button-start" href="/page-url" data-type="button">As an example</a>

There may be good reason for this that I am unaware of...

36degrees commented 7 years ago

Thanks for raising this.

This was previously discussed at length in #272, so it's worth reading through that for the background.

I believe the consensus was that the button role is appropriate as long as users expectations (and the way it's announced to assistive tech) are met - i.e. you can activate it using space, which is covered by the shim that was introduced as a result of that discussion.

NickColley commented 7 years ago

Going to close this out as per @36degrees referenced issue. Thanks for raising @trevorsaint 👍