News homepage with semantic HTML and aria-labeledby headings
Design comparison
Solution retrospective
As part of the "Introduction to web accessibility" learning path, I focused on using semantic HTML for all the elements, a clear hierarchy and structure to the HTML, and clear aria-labeledby
headings for each of the major landmarks in the page. Would appreciate hearing from others what other accessibility considerations I should be taking into account.
Community feedback
- @bccpadgePosted about 1 month ago
Hello @elisilk. Congratulations on completing this challenge!!!π
For the mobile navigation, you can use
<button>
tag rather than<a>
tag for the hamburger and close icons.<button> <span class="visually-hidden"> Open mobile navigation</span> <img src="assets/images/icon-menu.svg" alt="" > <img src="assets/images/icon-menu-close.svg" alt=""> </button>
Add
ARIA
to the<button>
- aria-expanded="false"
- aria-controls="nav"
- The aria-control on the button connects to the
nav
when you put a id="nav"
- The aria-control on the button connects to the
Using JavaScript you can use setAttribute of aria-expanded="false" to "true"
Here is an example: Project tracking intro component
More infoπ:
The visually-hidden CSS class will tell screen readers that this
<button>
will say open mobile navigation./* sometimes referred to as .sr-only */ .visually-hidden:not(:focus):not(:active):not(:focus-within) { clip-path: inset(50%); height: 1px; overflow: hidden; position: absolute; white-space: nowrap; width: 1px; }
To check accessibility on website
- Open your website in Google Chrome
- Go to the DevTools
- Click More Tabs button next to Memory
- Then click Lighthouse
Lighthouse analyzes the website with 4 categories
- Performance
- Accessibility
- Best practices
- SEO (Search Engine Optimization)
I hope you find this useful and don't hesitate to reach out if you have any questions.
Marked as helpful2@elisilkPosted about 1 month agoHi @bccpadge π,
Thanks the suggestion! I implemented the changeover to the
<button>
element and learned a bit about thearia-expanded
andaria-controls
attributes in the process. I appreciate you taking the time to look at my solution and offer feedback. πEli
0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord