Accessible Links - The Quick Guide
delicious • digg • stumble • float • dzone • Print Article • comments rss
If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!
Maybe not the sexiest or most glamorous topic for a blog post – but interesting nonetheless – the hyperlink is possibly the most commonly used of the HTML elements, and probably the most overlooked.
Have you ever stopped to think whether or not your links are actually living up to their full potential? Are they usable, accessible, effective and efficient? Probably not as much as you think.
This article will explore the intricacies of the hyperlink and how to make the most of the humble <a> tag.
1) Underlines
If you have a paragraph with links dotted in and among the copy they need to be identified as soon as possible by the user. The best way of doing this is to underline them. Target all paragraph links using:
p a{
text-decoration:underline;
}
This will make all links inside paragraphs underlined, and you can add further CSS rules to the above to expand the aesthetics and appearance of the links too. I would suggest removing the underline on hover to indicate the clickability (new word).
Underlining anything that isn’t a link is a big no-no, especially if it is in a body of text. People expect to be able to click it, and get mighty annoyed when they can’t!
The rules can be bent slightly with hyperlinks that either aren’t in long passages of text, or are obviously meant to be clicked (e.g. main navigations).
2) Colour
Colouring links consistently throughout your pages will massively increase their identification and ease of use. Keep all links contained in paragraphs the same colour, all links in your sidebar the same colour and the links in your footer, um, the same colour I guess.
Changing link colour on hover is an arbitrary decision; I would recommend that if you don’t remove the underline on a user hovering the link that you do alter the colour to indicate some level of interaction.
3) Cursors
This applies not just to links but anything that’s clickable – do not alter the cursor! Anything that can be clicked (especially links) should have the pointer cursor (literally give it the finger). Under no circumstance should you apply another form of element to a clickable element. I suggest adding this to your CSS file:
a, button, input[type="submit"], input[type="reset"]{
cursor:pointer!important;
}
This will give all your hyperlinks, buttons and submit/reset form elements a more logical cursor, indicating that they can (and should) be clicked.
4) Target
I mentioned this in [link]my previous article[/link], but please refrain from using the target (target=”_blank”) attribute on your links. This interrupts users’ workflow and also won’t validate under the Strict DOCTYPE.
If for whatever reason you are required to use the target=”_blank” attribute then you may want to use the following CSS to automatically indicate that a new window will be opened:
a[target^="_blank"]{
color:#f00;
padding-right:12px;
background:url(new-window.gif) bottom right no-repeat;
}
Where new-window.gif is a small arrow 10×10px wide – it will be shown on the far right of the link.
5) Title
This is a win-win situation in terms of both accessibility/usability and SEO. Some browsers (particularly those for disabled users) can bring up a list of links within a certain page – if you haven’t given each of these links a title attribute all the user will have to go on is the actual text of the link, and the location URI. Compare the following:
<a href="//csswizardry.com/">CSS Wizardry</a>
vs.
<a href="http://csswizardry.com/" title="CSS">CSS Wizardry</a>
It’s fairly obvious which one is the more accessible link. Users who isolate the links through their browsers get a description, and users who use their browser normally get a nice little tooltip telling them where the link they are about to click is going to take them.
I mentioned SEO benefits as well… Search engines spidering the second link will be able to give me a bit more weight in the SERPs for those keywords – SEs love keyword rich title tags (and alts but that’s another story).
6) Wording
In a similar vein as the above, the correct wording of your links has both accessibility and SEO benefits. For example:
For cheaper car insurance <a href="cheaper.html">click here</a>.
vs.
<a href="cheaper.html">Get cheaper insurance</a>!
When isolated, the first link simply reads “click here”, whereas the second reads “Get cheaper insurance”.
The latter is better practice in that it is a) a better call to action, b) a more accessible description of the links purpose and c) it’s got an infinitely meatier keyword count.
Note that I didn’t use the title attribute purely and simply so as not to over complicate things. A real life perfect example would be:
<a href="cheaper.html" title="Get Cheaper Car Insurance">Get cheaper insurance</a>!
7) Lists of links
If you ever make a list entirely of links, give each “li a” a bit of padding and display:block;. The reason for this is if you have a list of varying length links which are all stacked one above the other, users with motor handicaps may struggle navigating their mouse/pointing device over such cramped items:
ul li a{
padding:2px;
display:block;
}
Accesskeys
Accesskeys are a great way to allow users to navigate a site. They are used most often on critical links, i.e. your main navigation. They aren’t as important on outbound links to other sites you are referencing or smaller less important pages in your own site.
<a href="index.html" title="Return to the Home Page" accesskey="1">Home</a>
Also, they only need defining once per page. Say you have three links to your home page on your contact page, you need only define the accesskey to any one of those links.
In most browsers you hold Alt+accesskey. In Firefox you hold Shift+Alt+accesskey.
9) Keyboards
A lot of users have/choose to navigate with their keyboards. The issue this poses is that the :hover pseudo-class isn’t utilized by keyboard navigation, so any user tabbing through will not see any change in the link’s state when they’re over it. The way round this is to take your a:hover CSS rule:
a:hover{
...
}
and change it to this
a:hover, a:focus{
...
}
Now the same hover effects your mouse users get, your keyboards users get too!
That pretty much covers it, in a basic form of nutshell. You’re now on your way to being a hyperlink guru – a much coveted title, I’m sure ![]()
Great article. Your Accesskey example seems to be missing the accesskey option though.
Cheers Art, no idea how that happened. Mind you it was quite a rushed article…
As a fellow Blog Idol contestant, I finally got around to subscribing to your blog, I’ll probably keep the feed after the contest is over.
Although my comments are actually about two of your earlier articles concerning code commenting and use of tables. As an admin at WebAPP Network(the best free,open source perl CMS;even if I am a bit biased) I’ve whined about the lack of commenting we use in code often and wish it was far better done, or even just done a little bit.
As far as tables issues goes, I’ve listened to the whining concerning the tabled layout we have often over the past three years and I believe the next version finally does a major revamp on it, with the build version of this running on live site: http://www.Web-APP.net
However, I love the tabled layout myself, although wish it was structured better. I’ll probably consider not upgrading myself, on this table revamp issue as I hate the div problems I encounter when surfing sites.
Security is our core focus. My article yesterday touches on it. Our security guru gets off when the site is under attack and would really like me to spread the word that the WebAPP Network site is welcome to anyone who wishes to, to attack site. Although I myself don’t look forward to such things with my site using the WebAPP v1.0 SE, I’m confidant it would hold up. However, as I mentioned, our very arrogant security guru loves this sort of thing happening. So I’d prefer the attacks go there.
Myself, I find the WebAPP scripts a very good platform to build from. There’s a lot already there but more importantly its now highly secure compared to past versions and that of a competing Web-APP.org distributions.
If anyone would like to try it out. The v1.0 is available in the downloads section of both my site and The WebAPP Network site. Or I can make available for a limited time, a site that’s already installed and ready to play with as if it were your own if you’d rather that. Just sign up(register) at my site and mention this as you introduce yourself in the forums. I think you’ll like it.
Very nice
Good idea to set the width in the ul li a declaration as this will work in MSIE 6 as well as Firefox etc. Also if changing the color of the link, as in your demo page, you need to set the background color as well.
Good stuff though!