3 ms·
Regardless of the original intent (or lack thereof) behind them, HTML5 tags are more or less syntactic sugar for ARIA roles. Which means, if you care about acc
by strogonoff 4y ago
Regardless of the original intent (or lack thereof) behind them, HTML5 tags are more or less syntactic sugar for ARIA roles.
Which means, if you care about accessibility and want to pick the best element for the circumstances, you must know that you are deciding not on a tag but on element’s role.
Which means, the moment you find yourself asking “should I use <section> or <article>?”, or “should I use <nav> or <toolbar>?”, etc., you… might as well throw a <div> there for right now, and as soon as you’re done with the task head to ARIA docs. It’s a warning sign that you are lacking clarity as to the content hierarchy you’re dealing with.
Consult the source of truth (ARIA docs) instead of picking a role by proxy by reading HTML tag docs; give your div a well-informed choice of a role, and leave it to your linter to complain if it could be made briefer by changing it to a different tag that has the same role implicitly.
- curlftpfs 4y agoYou'd lose every element-specific browser behavior. A div with role=button doesn't handle, say, keydown events correctly like a <button>. You could rewrite every edge case for every element in JS if you wanted, but why? Just understand what the elements mean.