That Damn Ampersand

The Damn AmpersandThe ampersand drives me crazy. The ampersand is the punctuation mark "&" we use to represent the word and. It's not so much the character itself that irks me but how it effects the validation of my XHTML code.

In a valid XHTML document, you have to escape the ampersand, otherwise XML parsers will break when parsing the document. So, when typing the & character on this page, I must actually type &. Go ahead and view the source of this page to see for yourself. Simply typing & will make this page invalid according to the W3C standards for XHTML. All of my pages must be validated for me to sleep well at night and as of this moment, all of them are.

When I want to use the ampersand in an entry, I simply type & and I do so without even thinking about it now. My beef is with the URI of sites I may want to link to. For example, suppose I want to link to the "Law to force school until 18" article from the Toronto Star Website. The URI for this page is
http://www.thestar.com/NASApp/cs/ContentServer?pagename=thestar
/Layout/Article_Type1&c=Article&cid=1099782608603&call_pageid=
968332188492&col=968793972154.

Ideally, I'd simply copy and paste the URI into my XHTML document, but if I do this I'll be using ampersands and violating the standards. So, I have to manually replace all instances of & with &. It's really a pain in the butt and the Toronto Star is one of the worst offenders.

I wish news sources would stop using ampersands in their URIs. The BBC News website is an excellent example of how URIs should appear. If I want to link to the "Canadian freedoms 'under threat' article from the BBC, I simply reference http://news.bbc.co.uk/1/hi/world/americas/3984311.stm. Notice there are no ampersands. I can simply copy the URI and paste it into my document. No need to pause and detect offending characters so that I can replace them. It's all valid and there's much less work for me.

Validate or die.


Share this entry

Comments (1 - click here to join in!)

Watch Boosh Online

This update was really interesting, how often do you post to your blog? I've bookmarked this site and gave you guys a tweet, hope to read more soon!

January 9, 2010 @ 2:36 PM

Leave a comment


Only 1 comment? C'mon, we can do better... Leave a comment above and let's keep this conversation going!


« St. John's Maple Leafs 4, Edmonton Road Runners 3 Three For Three »