Region Role and Section - Learn Accessibility by Building a Quiz
See original GitHub issueDescribe the Issue
In Step 16 the tutorial told us to use both section and role="region"
.
According to MDN Web Docs about Region Role states that
Using the
<section>
element will automatically communicate a section has a role ofregion
if it is given an accessible name. Developers should always prefer using the correct semantic HTML element, in this case<section>
, over using ARIA.
And in MDN Web Docs <section> element also states that for best practice there should be a heading inside the section element for accessibility purposes.
I am now left wondering why do we still need to declare the role and aria-labelledby
in the section element in this step?
Thank you
Affected Page
Your code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="freeCodeCamp Accessibility Quiz practice project" />
<title>Accessibility Quiz</title>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<header>
<img id="logo" src="https://cdn.freecodecamp.org/platform/universal/fcc_primary.svg">
<h1>HTML/CSS Quiz</h1>
<nav>
<ul>
<li><a>INFO</a></li>
<li><a>HTML</a></li>
<li><a>CSS</a></li>
</ul>
</nav>
</header>
<main>
<form method="post" action="https://freecodecamp.org/practice-project/accessibility-quiz">
<section role="region" aria-labelledby="student-info">
<h2 id="student-info">Student Info</h2>
</section>
<section role="region" aria-labelledby="html-questions">
<h2 id="html-questions">HTML</h2>
</section>
<section role="region" aria-labelledby="css-questions">
<h2 id="css-questions">CSS</h2>
</section>
</form>
</main>
</body>
</html>
Expected behavior
To not use roles in section unless its a div and we’re building a semantic that is not defined in the HTML element?
Screenshots
No response
System
- Device: PC
- OS: Windows 10
- Browser: Brave
- Version: Latest
Additional context
No response
Issue Analytics
- State:
- Created a year ago
- Comments:6 (5 by maintainers)
Top GitHub Comments
If you want to turn these sections into landmarks then using a
section
element witharia-labelledby
is the best semantic option. You just don’t need to addrole="region"
.My comment above was a meeting note from our issue triage meeting. And now I read through your comments here and on the forum. Thank you @bbsmooth for a comprehensive explanation.
The proposal we had in the meeting was:
<div role="region" aria-labelledby="student-info">
<section>
element it will automatically have arole="region"
so you don’t have to add it manually. Also, it is better practice to use correct semantic HTML elements.” And we guide users to modify the code to:<section aria-labelledby="student-info">
I’m not sure what we should do regarding that it’s not recommended to add too many landmarks. I know we want to keep explanations short, but can we add brief notice about this point?