I’ve been having a lot of fun with jQuery recently. One of the things particularly easy to do with it is write nice and unobtrusive javascript (a good start when looking at progressive enhancement). This is largely down to the fact that it’s very easy to find particular elements within the DOM - with any level of specificity - and attach behaviour to them.
On the site I’ve been building at work, one particular example was to get jQuery to write in the “Print page” link, since that needs javascript.
// add print page link - since it can only work for JS, only add it for JS users
$('<li></li>') // create list item
.addClass('print') //add relevant class to it
.append('<a href="javascript:window.print();">Print this page</a>') //put in the link
.insertBefore('li a.foo'); //add before the li item with link of class 'foo'
The above example is slightly more verbose than it need be, but it illustrates some of the different built-in functionalities of jQuery quite well.
Continue reading Progressive enhancement with jQuery
Writing for the web is very different from writing for print. Key reasons for this are:
- Users scan web pages rather than reading every word.
- Users typically won’t give a web page their full attention. For example, they may also be listening to music and using instant messaging.
- Web pages are interactive.
The six elementary rules
George Orwell’s rules (”Politics and the English Language”, 1946) are just as relevant today for the web.
- Never use a metaphor, simile or other figure of speech which you are used to seeing in print. [The point here is not "print vs. web" but "avoid ones which are used all the time".]
- Never use a long word where a short one will do.
- If it is possible to cut out a word, always cut it out.
- Never use the passive where you can use the active.
- Never use a foreign phrase, a scientific word or a jargon word if you can think of an everyday English equivalent.
- Break any of these rules sooner than say anything outright barbarous.
Continue reading Web writing guidelines
This one’s pretty simple actually, so there’s not much to say about good practice with link text. However, I do keep seeing it being done wrong, so here’s an outline of the key things to consider.
The first thing to remember is that the link text should “identify the target of each link”. In other words, don’t use text like “click here”. Apart from the implication that the user must use a mouse, imagine what a screen reader user would have read out to them on tabbing from link to link and having the link text of each one read out!
Continue reading Link text
Here’s part one of three in follow-up to the Oxford Geek Night, to elaborate on the points I made about image alt text.
A quick recap (or introduction, if you weren’t there or haven’t seen my slides!):
An image’s alt text is presented to a user if their “user agent’ (the thing they’re using to browse web pages) does not display the image. e.g.
- A text browser is being used
- The user is blind and a screen reader reads out the web pages
Inclusion of the alt attribute on image (”<img>”) tags is required by the W3C specification.
Continue reading Image alt text
Two nights ago was the first Oxford Geek Night. This was basically a chance for web developers and designers to get together in a mixed business and social context.
I did one of the “microslots” - a five minute talk on “Avoiding accessibility pitfalls”. This is of course a huge area, and one I’d happily talk for hours about, so I focussed on three areas in which I keep seeing people trip up:
- Giving appropriate alt text
- Correct use of link text
- Using markup correctly
I’ll be elaborating on each of these areas in my next few posts; in the meantime, you can download my slides as a pdf.