Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are role="radiogroup" and role="radio" really necessary?

There are some ARIA tutorial websites use non-semantic markup and some javascript to demostrate the use of role="radiogroup" and role="radio" such as the following example:

<ul role="radiogroup">  
    <li tabindex="-1" role="radio" aria-checked="false">  
        <img role="presentation" src="radio-unchecked.gif">
        Option1
    </li>  
    <li tabindex="0"  role="radio" aria-checked="true">  
        <img role="presentation" src="radio-checked.gif">
        Option2
    </li>  
</ul>


But what's the point to use those roles when we already have semantic and javascript-less approach like:

<ul>  
    <li>  
        <input  id="opt1" type="radio" name="opt" value="1">
        <label for="opt1">Option1</label>
    </li>  
    <li>  
        <input  id="opt2" type="radio" name="opt" value="2">
        <label for="opt2">Option2</label>
    </li>  
</ul>
like image 570
Ian Y. Avatar asked Jun 21 '12 09:06

Ian Y.


People also ask

What does role group do?

The group role identifies a set of user interface objects that is not intended to be included in a page summary or table of contents by assistive technologies.

What is value in radio button HTML?

The value attribute is a string containing the radio button's value. The value is never shown to the user by their user agent. Instead, it's used to identify which radio button in a group is selected.

How do I tab through a radio button?

When focus moves to the group in which a radio button is selected, pressing Tab and Shift+Tab keys move focus to the radio button that is checked. Up Arrow and Down Arrow keys move focus and selection. Up Arrow key press moves focus and selection forward through the radio buttons in the group.


1 Answers

Because there are some people who really, really want custom designs for their form controls and will replace them with images and a pile of JavaScript regardless of there being semantically appropriate elements.

The roles just allow the damage to be mitigated when they do so.

like image 138
Quentin Avatar answered Sep 18 '22 12:09

Quentin