What values can the HTML5/XHTML role attribute have?

Html

Html Problem Overview


I was wondering what values are valid in the HTML5/XHTML role attribute?

Html Solutions


Solution 1 - Html

Here are the valid roles based on HTML 5.2...

  • alert
  • alertdialog
  • application
  • article
  • banner
  • button
  • cell
  • checkbox
  • columnheader
  • combobox
  • complementary
  • contentinfo
  • definition
  • dialog
  • directory
  • document
  • feed
  • figure
  • form
  • grid
  • gridcell
  • group
  • heading
  • img
  • link
  • list
  • listbox
  • listitem
  • log
  • main
  • marquee
  • math
  • menu
  • menubar
  • menuitem
  • menuitemcheckbox
  • menuitemradio
  • navigation
  • none
  • note
  • option
  • presentation
  • progressbar
  • radio
  • radiogroup
  • region
  • row
  • rowgroup
  • rowheader
  • scrollbar
  • search
  • searchbox
  • separator
  • slider
  • spinbutton
  • status
  • switch
  • tab
  • table
  • tablist
  • tabpanel
  • term
  • textbox
  • timer
  • toolbar
  • tooltip
  • tree
  • treegrid
  • treeitem

Solution 2 - Html

It appears that in HTML5, the contents of the role attribute is specified as a WIA-ARIA attribute. See, specifically, the last paragraph of section 3.2.3 "Global attributes", where it states:

> To enable assistive technology products to expose a more fine-grained interface than is otherwise possible with HTML elements and attributes, a set of annotations for assistive technology products can be specified (the ARIA role and aria-* attributes).

The role attribute is, then, further detailed in section 3.2.7 "WAI-ARIA", and provides an apparently normative table of semantics and values for the attribute on an element-by-element basis.

Note: The links to specific sections of the HTML5 specification above point to the "latest published version" of the HTML5 Technical Report at <http://www.w3.org/TR/html5/>;. A more current "editor's draft" version might be available. The TR will link to it on the title page of the document. As the specification is updated or transitions to a new phase of adoption, these links might break and will need to be updated.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionHELPView Question on Stackoverflow
Solution 1 - HtmlZimView Answer on Stackoverflow
Solution 2 - HtmlRobertBView Answer on Stackoverflow