Role=”text” is (presently) kinda not a thing, sorta.

this is my new favorite "why did you do this?" bit of code:

<span role="text" tabindex="0"> Text goes here </span>

— Scott O'Hara (@scottohara) December 4, 2017

That tweet contains some of my new favorite code to find, when poking through the source of websites and applications.

<span role="text" tabindex="0">
  Text goes here
</span>

It’s a perfect example of a developer trying to make something accessible (appreciate the effort), but unfortunately it widely misses the mark on what one should be doing with ARIA attributes.

Just a little bit of code can say a lot

Let’s break down the previously mentioned code snippet…

Put down the ARIA

It bares repeating, again and again, but please adhere to The first rule of ARIA.

If you can use a native HTML element or attribute with the semantics and behavior you require already built in, instead of re-purposing an element and adding an ARIA role, state or property to make it accessible**, then do so**.

Adding onto that statement, for fundamental elements of the web, e.g. text, links, buttons, lists, etc., there is absolutely no reason to double up ARIA roles on top of preexisting native semantics.

So next time you’re about to add a <button role="button">, <a href="..." role="link">, or use an unsupported role like <span role="text", instead just go grab another cup of coffee or something. As getting that extra cup of coffee will have the same effect on the accessibility of your element, as adding redundant roles will.