What is the role
HTML attribute used for? For whom is it indicated? Is it required for HTML elements?
P. S. The question “id, class and role for an element ” answers only a third of my question.
Answer 1, authority 100%
This attribute is used for semantic tags , which appeared in large numbers in HTML5 .
The role
attribute allows you to most clearly indicate the purpose of the page block / element when the user interacts with the site.
This attribute is optional and mostly formal.
The main and most commonly used values of role:
banner
– contains the main title or inner title of the page. For example the logo and the name of the site. It is recommended to use no more than once per page.complementary
– information block separated from the main content of the resource.contentinfo
– general information about the content of the page (for example, the footer of the site). It is recommended to use no more than once per page.definition
– indicates the definition of a term or concept.main
– acts as the main content of the document. It is recommended to use no more than once per page.navigation
– a set of elements designed to navigate through a document or related documents. It is recommended to use no more than once per page.note
– a note (supporting information) to the main content of the resource.search
– Specifies the scope to search for content.
Answer 2, authority 58%
The role
attribute, with appropriate values, is used by screen readers via speech or tactile output. It is specified not only for semantic elements. A complete list of values for all html elements can be found at w3.org