HTML landmarks

HTML landmarks are used to categorize and group content on a web page for better accessibility and SEO.[1]

## Contents

* 1 Sectioning elements
* 2 Landmark roles
* 2.1 Examples
* 3 Misuse
* 3.1 Examples of misuse
* 4 See also
* 5 References

## Sectioning elements

HTML5 included the addition of the following content sectioning elements, which inherit default landmark roles:[2]

HTML Sectioning Elements and Their Default Landmark Roles  Element  | Default Landmark Role

|

`<header>` | `banner` when in the context of the `<body>` element. The `<header>` element is not a `banner` landmark when it is a child of any of the following sectioning elements: `<article>`, `<aside>`, `<main>`, `<nav>`, `<section>`.[3]
`<nav>` | `navigation`
`<main>` | `main`
`<aside>` | `complementary`
`<form>` | `form` when it has an accessible name using one of the following attributes: `aria-labelledby`, `aria-label`, or `title`.[3]
`<footer>` | `contentinfo` when in the context of the `<body>` element. The `<footer>` element is not a `contentinfo` landmark when it is a child of any of the following HTML sectioning elements: `<article>`, `<aside>`, `<main>`, `<nav>`, `<section>`.[3]
`<section>` | `region` when it has an accessible name using one of the following attributes: `aria-labelledby`, `aria-label`, or `title`.[4]

## 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.[5]

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.[6]

### Examples

<div role="banner">
<h1>Hello, world!</h1>
</div>

The code above is the same as the following more widely accepted version:[7]

<header>
<h1>Hello, world!</h1>
</header>

## 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.[8]

Additionally, you should not try to alter sectioning elements' default roles.[9]

### Examples of misuse

The role of `main` on the `<main>` element is useless, as it already inherits that role as its default landmark role:

<main role="main">
<p>Hello world!</p>
</main>

Applying the `form` role to `<header>` is semantically improper, because it overrides `<header>`'s the default role of `banner`:

<header role="form">
<!--Some HTML code here-->
</header>

## See also

* Semantic Web
* Semantic HTML
* Web accessibility
* HTML element
* HTML attribute

## References

1. ↑ Clark, Richard; Studholme, Oli; Murphy, Christopher; Manian, Divya (in en). Beginning HTML5 and CSS3. pp. 75–81.
2. ↑ Wood, Adam. "HTML5: What's New in The Latest Version of HTML?" (in en-US). https://html.com/html5/.
3. ↑ 3.0 3.1 3.2 "HTML Sectioning Elements: ARIA Landmarks Example". https://www.w3.org/TR/wai-aria-practices/examples/landmarks/HTML5.html.
4. ↑ "ARIA: region role - Accessibility | MDN" (in en-US). https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/region_role.
5. ↑ "How Not To Use Aria". https://cccaccessibility.org/web-1/web-developer-tutorials/how-not-to-use-aria.
6. ↑ "Using ARIA: Roles, states, and properties - Accessibility | MDN" (in en-US). https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques.
7. ↑ "How to Use ARIA Roles, Properties, and States in HTML". 17 November 2020. https://webdesign.tutsplus.com/tutorials/aria-roles-properties-and-states-in-html--cms-36097.
8. ↑ "WAI-ARIA Authoring Practices 1.1". https://www.w3.org/TR/wai-aria-practices-1.1/Overview.html.
9. ↑ "Using ARIA". https://www.w3.org/TR/using-aria/Overview.html.

0.00

(0 votes)

Original source: https://en.wikipedia.org/wiki/HTML landmarks. Read more

|

Retrieved from "https://handwiki.org/wiki/index.php?title=HTML_landmarks&oldid=3982581"