HTML landmarks
HTML landmarks are used to categorize and group content on a web page for better accessibility and SEO.{{Cite book |last1=Clark |first1=Richard |title=Beginning HTML5 and CSS3 |last2=Studholme |first2=Oli |last3=Murphy |first3=Christopher |last4=Manian |first4=Divya |pages=75–81 |language=en}}
Sectioning elements
HTML5 included the addition of the following content sectioning elements, which inherit default landmark roles:{{Cite web |last=Wood |first=Adam |title=HTML5: What's New in The Latest Version of HTML? |url=https://html.com/html5/ |access-date=2022-03-13 |website=HTML.com |language=en-US}}
class="wikitable"
|+HTML Sectioning Elements and Their Default Landmark Roles !Element !Default Landmark Role |
<header>
| |
<nav>
| |
<main>
| |
<aside>
| |
<form>
| |
<footer>
| |
| |
Landmark roles
The role
attribute is used to define an element's role on a page. When sectioning elements were introduced, the role
attribute became used less for landmarking. This is because roles were applied by default to most sectioning elements, therefore, they were more widely used and accepted for their simplicity.{{Cite web |title=How Not To Use Aria |url=https://cccaccessibility.org/web-1/web-developer-tutorials/how-not-to-use-aria |access-date=2022-03-13 |website=cccaccessibility.org}}
The role
attribute is not only used for assigning roles to content sections. The attribute can also be used to assign roles to many other elements, although it is used less nowadays due to new semantic HTML elements.{{Cite web |title=Using ARIA: Roles, states, and properties - Accessibility {{!}} MDN |url=https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques |access-date=2022-03-13 |website=developer.mozilla.org |language=en-US}}
= Examples =
Hello, world!
The code above is the same as the following more widely accepted version:{{Cite web |title=How to Use ARIA Roles, Properties, and States in HTML |url=https://webdesign.tutsplus.com/tutorials/aria-roles-properties-and-states-in-html--cms-36097 |access-date=2022-03-13 |website=Web Design Envato Tuts+|date=17 November 2020 }}
Hello, world!
Misuse
Following the addition of sectioning elements in HTML5, there was confusion regarding whether role attributes were needed for sectioning elements. It is in fact redundant to give sectioning elements the role attribute.{{Cite web |title=WAI-ARIA Authoring Practices 1.1 |url=https://www.w3.org/TR/wai-aria-practices-1.1/Overview.html |access-date=2022-03-13 |website=www.w3.org}}
Additionally, you should not try to alter sectioning elements' default roles.{{Cite web |title=Using ARIA |url=https://www.w3.org/TR/using-aria/Overview.html |access-date=2022-03-13 |website=www.w3.org}}
= Examples of misuse =
The role of main
on the <main>
element is useless, as it already inherits that role as its default landmark role:
Hello world!
Applying the form
role to <header>
is semantically improper, because it overrides <header>
's the default role of banner
: