Last active
November 6, 2023 21:10
-
-
Save benschwarz/1106038 to your computer and use it in GitHub Desktop.
Using ARIA roles with <header>, <footer> and <aside>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<body> | |
<header role="banner"> | |
<a href="/" rel="home">My company</a> | |
<nav role="navigation"> | |
<a href="/about">About</a> | |
<a href="/contact">Contact</a> | |
</nav> | |
</header> | |
<section role="main"> | |
<h1>The meat and potatos</h1> | |
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p> | |
</section> | |
<footer role="contentinfo"> | |
<p>© Copyright Ben Schwarz 2011</p> | |
</footer> | |
</body> | |
</html> |
I would concur with Sean.
Agreed re: <main role="main">
Also: "potatoes"
@seanwalsh, @professordino — <main>
didn't exist in 2011.
@benschwarz so why not back to the future and update the gist?
If you put
you don't need the role at all. Screen readers and assistive tech will understand what it is just fine.The role attribute is for areas where there is some ambiguity or possible confusion. Like headers, navs and footers which can be placed in different contents and multiple areas throughout a page. Or if you explicitly want to use an element for something it's not normally used for. LIke an li as a button:
Also there can only be one
element per page. Unlike header, footer, nav which can be in numerous contexts. Just FYI
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Shouldn't
section
be amain
element?