From dcfb172704f3afb68a30425029ec834be2883274 Mon Sep 17 00:00:00 2001 From: bt Date: Sat, 8 Jun 2024 13:22:19 -0400 Subject: More content porting, on-going markdown changes for lowdown support --- build/skip-to-content/index.html | 79 ++++++++++++++++++++++++---------------- 1 file changed, 47 insertions(+), 32 deletions(-) (limited to 'build/skip-to-content') diff --git a/build/skip-to-content/index.html b/build/skip-to-content/index.html index be50b94..7a72d31 100644 --- a/build/skip-to-content/index.html +++ b/build/skip-to-content/index.html @@ -1,51 +1,61 @@ - + Skip to Content Button - - + + +
-

Skip to Content Button

+

Skip to Content Button

+

2019-03-25

-

One of the golden rules for testing your website's accessibility is the "keyboard-only" audit. This is where you test navigating through your entire site without the use of a mouse, but instead rely solely on tabbing through your content.

-

Unfortunately, one item is normally overlooked during this audit - a "skip to content" context button. Including a "skip to content" navigation item in your project is extremely useful because:

+ +

One of the golden rules for testing your website’s accessibility is the “keyboard-only” audit. This is where you test navigating through your entire site without the use of a mouse, but instead rely solely on tabbing through your content.

+ +

Unfortunately, one item is normally overlooked during this audit - a “skip to content” context button. Including a “skip to content” navigation item in your project is extremely useful because:

+ -

The HTML

+ +

The HTML

+

For the sake of this demo we will assume that we currently have the following navigation setup in our project:

-
<nav role="navigation">
-    <a href="/">Home</a>
-    <a href="/about">About</a>
-    <a href="/archive">Archive</a>
-    <a href="/atom.xml">RSS</a>
-</nav>
+
+
<nav role="navigation">
+    <a href="/">Home</a>
+    <a href="/about">About</a>
+    <a href="/archive">Archive</a>
+    <a href="/atom.xml">RSS</a>
+</nav>
 
-

Now for the easy part - adding our simple content skip link with it's own custom skip-content class:

-
<nav role="navigation">
-    <!-- Skip to content button -->
-    <a class="skip-content" href="#main">Skip to Content (Press Enter)</a>
-    <a href="/">Home</a>
-    <a href="/about">About</a>
-    <a href="/archive">Archive</a>
-    <a href="/atom.xml">RSS</a>
-</nav>
+
+

Now for the easy part - adding our simple content skip link with it’s own custom skip-content class:

+ +
<nav role="navigation">
+    <!-- Skip to content button -->
+    <a class="skip-content" href="#main">Skip to Content (Press Enter)</a>
+    <a href="/">Home</a>
+    <a href="/about">About</a>
+    <a href="/archive">Archive</a>
+    <a href="/atom.xml">RSS</a>
+</nav>
 
-

- Sidenote: in this demo we are making the assumption that the main content block has an id of "main" associated with it. Hence the skip content button linking to #main. -

-

The CSS

-

Our first task is to make sure this new link isn't visible or interactive by default unless the user explicitly tabs through the navigation. We do so by positioning the link outside of the main content view. It is important to use this absolute position style instead of setting the display property to none, since the display property technique will fully remove the element from the DOM (bad accessibility practices).

+ +

The CSS

+ +

Our first task is to make sure this new link isn’t visible or interactive by default unless the user explicitly tabs through the navigation. We do so by positioning the link outside of the main content view. It is important to use this absolute position style instead of setting the display property to none, since the display property technique will fully remove the element from the DOM (bad accessibility practices).

+
a.skip-content {
     background: grey;
     color: white;
@@ -55,13 +65,18 @@
     top: 0;
 }
 
-

Almost there

+ +

Almost there

+

Now we just re-position the element when the user focuses on the link with a keyboard tab:

+
a.skip-content:focus {
-    left: 1rem; /* Whatever desired position */
+    left: 1rem; /* Whatever desired position */
 }
 
-

All Done

+ +

All Done

+

This is a very basic accessibility win you can implement in your current projects with next to zero effort. Enjoy!