-
-
Notifications
You must be signed in to change notification settings - Fork 557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to: Article how to make an accessible nav with dropdowns #1472
base: main
Are you sure you want to change the base?
How to: Article how to make an accessible nav with dropdowns #1472
Conversation
Just realized I might have totally misread and missed a step with creating an issue to properly link this to sorry. I'll have another read of the contributing guides in the morning and try an do this properly! |
@jimbateson Firs off, thanks for your submission! I'm really excited to review it, but have been a bit busy lately. Don't worry about filing the issue, it's on my radar 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great contribution - love that it’s focused on a specific item.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jimbateson I'm sorry this took so long to get to. My being busy turned into a health issue, but I'm in a better place now.
I've left some comments and suggested edits here to consider. One other big-picture thing I'm thinking is we should also provide an example of the JavaScript that powers the toggling. What do you think about creating a CodePen example for the post, so readers can play with/reference it?
- howto | ||
--- | ||
|
||
Navigation is a critical part of any application and can often involve many levels of nesting. It allows people to complete journeys and find the information they need. So making it accessible is key. HTML5 includes the <nav> section element to help with this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Navigation is a critical part of any application and can often involve many levels of nesting. It allows people to complete journeys and find the information they need. So making it accessible is key. HTML5 includes the <nav> section element to help with this. | |
Navigation is a critical part of any application and can often involve many levels of nesting. It allows people to complete journeys and find the information they need. So making it accessible is key. HTML5 includes the <code><nav></code> landmark element to help with this. |
Suggesting two things here:
- Wrapping code in a
code
element, which I will be doing for other instances. - Using "landmark" in place of "section", as section has a specific meaning within the context of landmark elements/roles.
|
||
Navigation is a critical part of any application and can often involve many levels of nesting. It allows people to complete journeys and find the information they need. So making it accessible is key. HTML5 includes the <nav> section element to help with this. | ||
|
||
## The nav section element |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
## The nav section element | |
## The <code><nav></code> landmark element |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue I came across with trying to wrap this one in anything that represented code, was that when it parses this to turn it into a heading in the table of contents, I think it's trying to render a <nav>
(or just skipping it, as maybe unsafe?) Is there an available filter could possibly use where those are generated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oof, yeah. Let's ignore wrapping code in the headings for now, and I'll get to the bottom of this bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I probably should have opened one when I spotted it writing this sorry, but wasn't sure if it was intended. Anyway, sounds good, thank you :)
|
||
## The nav section element | ||
|
||
Let's start with a quick overview of <nav>. The <nav> section element has semantic meaning and comes with accessibility benefits by using it to mark-up sections of navigation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's start with a quick overview of <nav>. The <nav> section element has semantic meaning and comes with accessibility benefits by using it to mark-up sections of navigation. | |
Let's start with a quick overview of <code><nav></code>. The <code><nav></code> landmark element has semantic meaning and comes with accessibility benefits by using it to mark-up sections of navigation. |
Let's start with a quick overview of <nav>. The <nav> section element has semantic meaning and comes with accessibility benefits by using it to mark-up sections of navigation. | ||
|
||
<blockquote> | ||
<p>The <nav> HTML element represents a section of a page whose purpose is to provide navigation links, either within the current document or to other documents. Common examples of navigation sections are menus, tables of contents, and indexes.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<p>The <nav> HTML element represents a section of a page whose purpose is to provide navigation links, either within the current document or to other documents. Common examples of navigation sections are menus, tables of contents, and indexes.</p> | |
<p>The <code><nav></code> HTML element represents a section of a page whose purpose is to provide navigation links, either within the current document or to other documents. Common examples of navigation sections are menus, tables of contents, and indexes.</p> |
|
||
### Semantics | ||
|
||
The <nav> element will communicate a role of navigation-equal to setting `role="navigation"`, (this may still need to be added if needing to [support some assistive technology](https://a11ysupport.io/tech/aria/navigation_role)) meaning it can be easily navigated to by people with screen readers—as a landmark. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The <nav> element will communicate a role of navigation-equal to setting `role="navigation"`, (this may still need to be added if needing to [support some assistive technology](https://a11ysupport.io/tech/aria/navigation_role)) meaning it can be easily navigated to by people with screen readers—as a landmark. | |
The <code><nav></code> element will communicate a role of navigation-equal to setting `role="navigation"` to assistive technology. This allows people using screen readers to easily identify it as navigation and navigate to it when navigating by landmarks. | |
Note that adding `role="navigation"` role may still be needed if you need to [support some older assistive technology](https://a11ysupport.io/tech/aria/navigation_role). |
Suggesting breaking this apart to communicate:
- What
nav
does under the hood, - How people can use it, and
- Separate support concerns a bit so people don't mistakenly skim and add redundant ARIA.
|
||
## Skip links | ||
|
||
Although not technically required to make accessible navigation, making sure your site has a 'skip link' (usually visually hidden until tabbed to) that can bypass the main site navigation is a handy usability feature. It allows someone to jump directly to a page's <main> landmark, skipping common and repeated site areas, such as the navigation so the person does not need to traverse this content on every page. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although not technically required to make accessible navigation, making sure your site has a 'skip link' (usually visually hidden until tabbed to) that can bypass the main site navigation is a handy usability feature. It allows someone to jump directly to a page's <main> landmark, skipping common and repeated site areas, such as the navigation so the person does not need to traverse this content on every page. | |
Although not technically required to make accessible navigation, making sure your site has a [skip link](https://www.a11yproject.com/posts/skip-nav-links/) that can be set to bypass the main site navigation is a handy usability feature. It allows someone to skip repeated site areas, such as the main navigation, so someone using assistive technology does not need to traverse this repetitive content on every page. |
- Linking to our post on skip links, so a reader can learn more about them.
- Skip links don't target the
main
landmark automatically, so rephrasing to not suggest that.
|
||
## Alternatives | ||
|
||
Multi-level navigation with dropdowns often referred to as 'mega menus' can often be complex and need some thought to navigate. In certain cases, we might want to consider an alternative. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really appreciate that you're providing segue paragraphs after your section headings 🙂
source: Adrian Roselli | ||
- title: "Navigation role support" | ||
url: https://a11ysupport.io/tech/aria/navigation_role | ||
source: Accessibility Support | ||
- title: "Top 5 rules of ARIA" | ||
url: https://www.deque.com/blog/top-5-rules-of-aria/ | ||
source: Deque | ||
- title: "Are your anchor links accessible?" | ||
url: https://amberwilson.co.uk/blog/are-your-anchor-links-accessible/ | ||
source: Amber Wilson | ||
- title: "Local Navigation Is a Valuable Orientation and Wayfinding Aid" | ||
url: https://www.nngroup.com/articles/local-navigation/ | ||
source: Nielsen Norman Group | ||
- title: "Cognitive accessibility" | ||
url: https://developer.mozilla.org/en-US/docs/Web/Accessibility/Cognitive_accessibility | ||
source: MDN Web Docs | ||
- title: "Fable assisitve technology glossary" | ||
url: https://makeitfable.com/glossary/ | ||
source: Fable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
source: Adrian Roselli | |
- title: "Navigation role support" | |
url: https://a11ysupport.io/tech/aria/navigation_role | |
source: Accessibility Support | |
- title: "Top 5 rules of ARIA" | |
url: https://www.deque.com/blog/top-5-rules-of-aria/ | |
source: Deque | |
- title: "Are your anchor links accessible?" | |
url: https://amberwilson.co.uk/blog/are-your-anchor-links-accessible/ | |
source: Amber Wilson | |
- title: "Local Navigation Is a Valuable Orientation and Wayfinding Aid" | |
url: https://www.nngroup.com/articles/local-navigation/ | |
source: Nielsen Norman Group | |
- title: "Cognitive accessibility" | |
url: https://developer.mozilla.org/en-US/docs/Web/Accessibility/Cognitive_accessibility | |
source: MDN Web Docs | |
- title: "Fable assisitve technology glossary" | |
url: https://makeitfable.com/glossary/ | |
source: Fable | |
source: Adrian Roselli |
We typically don't re-list links used in the post, and instead use this section for links that are topically-related that allow for further exploration.
@ericwbailey absolutely no problem at all, glad you're feeling better and hope everything is ok. Thank you for the review and feedback, and sorry that there's so much I need to tweak! Definitely a great learning experience. I'll start making the suggested changes, and agree that an example codepen would be very useful! I'll get these done ASAP :) |
@jimbateson Awesome! I think this post is also in really good shape. <ost of my feedback is just style nitpicks, and I'm really excited to publish it 🙂 Speaking of which, could you also add yourself to |
Apologies for going a bit quiet on this one. Done one round of changes, the low-hanging stuff, and will make some time to do the rest of the amends in the next week or so. Thanks for your patience :) |
@@ -62,26 +44,30 @@ Here's the example markup that we'll build up throughout this article. It's wort | |||
|
|||
### Semantics | |||
|
|||
The <nav> element will communicate a role of navigation-equal to setting `role="navigation"`, (this may still need to be added if needing to [support some assistive technology](https://a11ysupport.io/tech/aria/navigation_role)) meaning it can be easily navigated to by people with screen readers—as a landmark. | |||
The <code><nav></code> element will communicate a role of navigation-equal to setting `role="navigation"`, (this may still need to be added if needing to [support some assistive technology](https://a11ysupport.io/tech/aria/navigation_role)) meaning it can be easily navigated to by people with screen readers—as a landmark. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need the parenthetical here.
- support for nav being exposed as a landmark is very solid.
- the a11ysupport page you link to is for role=navigation and AT support for that role, so linking to it isn't even relevant here, since this page isn't for support of the element)
@ericwbailey Hey, hope you're doing ok, I'm so so sorry for the delay in getting this over the line. I've created a CodePen example of a the nav dropdowns - https://codepen.io/_jamesbateson/full/rNrJWpv (let me know if this ok! - just gonna do some final checks/tests on this in the morning). Just wondering how you would prefer me to embed this? Was going to go for the HTML embed option with the click to run option for perf gains and then only people who wish to see/play with it would need to use it? But if you'd prefer I just had it as a link then that's cool as well! Couldn't see any other embed examples in other posts or anything in the content style guide on it, but apologies if I've missed anything there! |
@davatron5000 Hey, hope you don't mind the mention here. Just re-opened my PR for the How To make accessibile nav with dropdowns article. I had completed the majority of the feedback from Eric, and had created a Codepen that people could see examples and play around with. Was just awaiting that Codepen to be checked and approved for suitability (linked in last comment) and also for any guideance on how is preferable to embed codepens on the site. No rush at all, but just thought would mention. Many thanks, |
Thanks @jamesbatesoncode. I'm verrryy far behind on some review and management tasks here. But I'll try to get on this stuff at some point soon. |
Navigation is a critical part of any application and can often involve many levels of nesting. It allows people to complete journeys and find the information they need. So making it accessible is key.
PR to add the article page into the posts /how to section.
Just a couple of notes sorry:
<nav>
. If you would like me to standardize this, I'm happy to do that. It seemed a particular issue in the front matter and headings translating to the in-page anchor navigation. May have missed something obvious here though!Sorry it's taken so long to get this into PR as well.