You might argue is full screen menu good idea in the first place. But it can be attractive and useful in the same way as modal dialog when done right. First step is to make it fit in your site design. Not all sites have a natural place for full screen menu or modal dialog.
Then work hard creating accessible full screen menu and you’re done! In this article I use Munsa WordPress theme as an example. From demo site you can check the final result.
For sighted users there are couple of important points we should consider when creating full screen navigation.
First, remember color contrast. Menu buttons and link colors should have enough color contrast against background color. Also follow other accessibility guidelines.
Second, disable scrolling on html
or body
element is probably good idea when you open full screen menu. That’s because I don’t want to scroll body element or have two scroll bars when full screen menu is opened. You can do that using one line of CSS when adding class disable-scroll-when-menu-is-open
via Javascript:
.js.disable-scroll-when-menu-is-open { overflow: hidden; }
In the same time take care that you can scroll the navigation element if it’s taller than site body element. Otherwise users could not reach all the menu items.
Fix this using overflow CSS rule:
.js .main-navigation { overflow: auto; }
Did you notice the js
class? We talk about that in next chapter.
Sometimes users disable Javascript or it just doesn’t load. These users should still be able to see full screen menu items. This can be achieved by adding no-js
class to HTML element. When Javascript is available, change no-js
to js
class programmatically. In Twenty Sixteen WordPress Theme this done via wp_header
hook.
function twentysixteen_javascript_detection() { echo "<script>(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);</script>\n"; } add_action( 'wp_head', 'twentysixteen_javascript_detection', 0 );
After that it’s a matter of styling the full screen menu using no-js
or js
classes.
Quick tip: In Chrome you can disable Javascript by entering URL chrome://chrome/settings/content
. From there check Do not allow any site to run Javascript.
Article Links are not buttons. Neither are DIVs and SPANs sums it up really well.
With all that said use buttons for triggering full screen menu.
When full screen menu is closed menu items should not be keyboard focusable when tabbing trough the site using Tab or Shift+Tab. This is because keyboard users might get lost where they are navigating. This can be done by using display: none
and display: block
CSS on menu element.
display: none
when menu is closed.display: block
when menu is opened. Now menu items are focusable.It’s even more important to shift focus when toggling full screen menu.
When tabbing through menu items do not lose focus outside the full screen menu.
It’s also important to provide users an escape route and close the menu when they want. Close button should be part of the focusable elements inside full screen menu. But also close the menu when user press Escape key. And remember to shift focus back to where it was in this case also.
I didn’t want to put too much code examples in this article. Instead I wanted to give ideas what you should consider when building accessible full screen menu. But do not fear, you can check all the code from Munsa Lite version in Github repo.
Let me know if I screwed this accessibility article badly or you have ideas to improve it.