The purpose of the “role” attribute I see on the theme files

What is the purpose of the “role” attribute in the WP themes?

For example, in the WP3 default theme we have this in footer.php

Read More

I searched for the string “contentinfo” and found that this is the only occurrence in the default theme folder.

What’s it’s purpose? How is it used?

Related posts

Leave a Reply

2 comments

  1. role is an XHTML attribute used to identify the context of elements on the page. The search bar will also render with role="search" on a WordPress site.

    You can read more about it at the W3C specification site.

    To answer your specific question, role="contentinfo" identifies “Meta information about the content on the page or the page as a whole.”

    The role attribute itself can be used by other applications (i.e. screen readers) to determine the purpose of the elements on the page. It gives things a stronger meaning than the explicit names we use for element IDs (which aren’t codified in any way).