I have just learnt about menuitemradio
when I was searching about radio
role on MDN.
However, seems there is no explanation about the difference between them..
Can I confirm that they are actually the same, but:
menuitemradio
role can only be used inside <menu>
or element with role="menu"
radio
role should used inside role="radiogroup"
Are these correct?
Additionally, so that:
radio
role be used in <menu>
or role="menu"
?The roles menuitemradio
and radio
are not the same.
The radio
role is the role that HTML's native radio buttons have (<input type="radio">
). This is a role for custom radio buttons, which should be grouped in an element with the radiogroup
role.
The menuitemradio
role is not an alternative to the above; it does not represent a radio button. It is a kind of option in a set of options in a menu, where only one of those options can be selected at any time. An example is the setting for the bookmarks toolbar in Firefox:
Elements with this role can only be used inside element with the following roles: menu
, menubar
or (if no other role accurate describes the container role) group
.
Radio buttons or custom element with the radio
role should not be used in menus.