VOOZH about

URL: https://www.geeksforgeeks.org/html/what-is-the-purpose-of-role-attribute-in-html/

⇱ What is the purpose of "role" attribute in HTML? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

What is the purpose of "role" attribute in HTML?

Last Updated : 1 Jul, 2024

The main purpose of the role attribute is to bolster ARIA i.e. Accessible Rich Internet Applications which helps in providing richness and quality from a semantic perspective. Moreover, role attribute makes a website more facilitative, and using this attribute is considered a good practice. Generally, the role is necessary for languages that do not define their role attribute.

Example: The example below shows the "role" attribute in HTML.

Output:

👁 ii1
Output

Note: The output doesn't show any significant thing to notice. This shows that even if the role attribute is not used in the code, then also it won't affect our code and output. By using role attributes, we get to avail features like accessibility, device adaptation, server-side processing, complex data description, and many more such features. Thus role attribute is advised to be used for getting better performance of the code.

Comment