tags:

views:

23

answers:

2

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

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?

+2  A: 

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).

EAMann
I see. then the role attribute has nothing to do with how the content is displayed?
rxn
Correct. It's just used by some systems to identify common page elements like search, headline, meta information ("contentinfo"), etc. This way certain applications can strip out entire sections of the page they deem unnecessary to a particular display situation (like automated re-sizing/layout optimization for mobile devices).
EAMann
A: 

It is also part of the WAI-ARIA specification (Accessible Rich Internet Applications)

You can also read about it on the W3C Specifications site

danixd