Hicks

You’re reading all articles on The Hickensian tagged 'accessibility'

skip navigation links

A recent article at The Web Standards Project alerted designers that ‘Skip Navigation’ links, traditionally hidden with the CSS property display:none, are invisible to screenreaders. This hadn’t occurred to me, even though I knew it was a problem with Fahner Image Replacement, which also uses display:none.

If you’ve got a long list of navigation links, skip links give users the option to go straight to the content, useful if you have a textbrowser, PDA or screenreader (doh!). It can be particularly painful to hear a screenreader speak al long list of links before finally getting to the content.

Put ‘em somewhere else

One way around this is to use a layout technique that allows navigation to be placed after the content, removing the need for the link. The Layout Reservoir at Blue Robot has useful examples on how this can be done. Navigation is positioned using position:absolute, which takes it out of the normal flow of the page, allowing it to go anywhere in your HTML. This won’t always be possible of course, and if you do, you’ll need to add a ‘skip to navigation’ link instead!

Hide ‘em

The following workaround was developed by Bob Easton, who wrote the original article on CSS Discuss, and works in the top 3 screenreaders – Jaws 4.51, Window-Eyes 4.5(beta) and IBM Home Page Reader 3.02.

<div class=“skiplink”><a href=”#content”>Skip Navigation</a> </div>

.skiplink { position: absolute; left: -1000px; width: 990px; font-size:1px; line-height:1; }

As you can see, it places the content off the screen to the left. Bob also added width, font-size and line-height to allow for extra information such as a menu of your accesskeys. The width rule is a failsafe, to make sure that div doesn’t become visible. If your link is a small simple affair, you can remove the width and font attributes. Tom Gilder extends this further , with a clever technique that makes the div visible when a user is tabbing through.

Don’t hide ‘em

However, Joe Clark argues the case for making these links visible. He lists several ways of doing this, and keeping it small, suggesting that just the word ‘skip’ would be acceptable.

skip links update

The suggestion in my last post was kindly tested by Bob Easton, who wrote the original article on CSS Discuss. It only worked in 2 of the top 3 screenreaders. It works in Jaws 4.51 and IBM Home Page Reader 3.02, but failed in the number 2 – Window-Eyes 4.5(beta). However, Bob suggests the following, which he has tested and does work in all 3:

.hide {
	position: absolute;
	left: -1000px;
	width: 990px;
	font-size:1px; line-height:1;
	}

As you can see, it places the content off the screen to the left. He also added width, font-size and line-height to “allow placing very large blocks of assistive text over there in hidden space”. Great – at least we know of a tested way of working with all 3. Thanks Bob!

Dave Shea offers this more compact version:

.hide {
	position: absolute;
	left: -999px;
	width: 990px;
	}

You can even remove the width if you’ve just got a ‘skip navigation’ link, but Bob’s original suggestion allows you to add more than just a ‘skip navigation’ link, such as a menu of your accesskeys. Tom Gilder extends this further, with a clever technique that makes the div visible when a user is tabbing through.

Bob has also set up a test suite for screen readers, trying 7(!) different solutions in total, including some that were suggested in the comments of the last post. If you have a screenreader, head over and get testing.

skip navigation solutions

I’ve just been reading on The Web Standards Project about the fact that ‘Skip Navigation’ links hidden with the CSS property display:none are invisible to screenreaders. This hadn’t occurred to me, even though I knew it was a problem with Fahner Image Replacement, which uses the same property.

Skip Navigation links give users the option to go straight to the content, useful if you use a textbrowser, PDA or screenreader (doh!). One way around this is to use a layout technique that allows navigation to be placed after the content, removing the need for the link. The Layout Reservoir at Blue Robot has useful examples on how this can be done. Navigation is positioned using position:absolute, which takes it out of the normal flow of the page, allowing it to go anywhere in your HTML. This won’t always be possible of course.

Another way is to use a similar technique to Seamus Leahy’s Image Replacement method at CSS Play, which is known to work with screenreaders. If your skip link looks like this:

&lt;div class="hide"&gt;&lt;a href="#content"&gt;Skip Navigation&lt;/a&gt;&lt;/div&gt;

Then your CSS would look like this:

.hide {
	height: 0;
	width: 0;
	overflow: hidden;
	position: absolute; /* for the benefit of IE5 Mac */
}

Like display:none, this won’t take up any ‘physical space’. The only browser I found that had a problem with this was IE5 Mac, but it behaved itself after adding position:absolute to the code.

Please note: This has since been tested in screenreaders, and it isn’t quite up to the job. See the next post.