Code examples
Use semantic HTML
This semantic HTML contains all accessibility features by default.
Skip to main content Not main contentAbout main content
The main content of the page belongs here.
When you can’t use semantic HTML
This custom main element requires extra attributes.
Developer notes
Name
- Typically doesn’t have a name other than its role.
- If a page has multiple
<main>
landmarks, then each should have a unique programmatic label.- Use
aria-label="Content name"
when there is not a visible content label. aria-labelledby="content-id"
can be used when the content label is a visible heading or existing page text.
- Use
Role
- Identifies itself as a main landmark
- If a non-semantic element must be used (like a
<div>
) userole="main"
.
Group
- must contain the main content of the page.
- Ideally appears only once per Web page.
Focus
- Can be targeted with a skip link, but isn’t focusable with the tab key
- Use
tabindex="-1"
to make the main targetable with a skip link.