So, following on from my last blog, I've now done the research I mentioned, and found out that the way to deal with ampersands in URLs is to write them as XML entities, i.e. '&', which is slightly embarrassing, as that should have occurred to me given that I've been using XML for nearly a decade.
And the XHTML-approved way of making a hyperlink open a new window is to replace the 'target' attribute with an 'onclick' attribute which calls the relevant JavaScript function to do it.
Something else I've just learned, having just previewed this blog, is that typing '&' out in full is more than a bit dumb, as the browser, of course, renders it as '&'; time for a sneaky trick to fool the browser. One last question: how can a modern browser possibly not know that 'blog' is a proper word?
Reflections on life from a (retired) software engineer wondering how (considerably more than) half a century of it managed to get behind him.
Search This Blog
Showing posts with label ampersands. Show all posts
Showing posts with label ampersands. Show all posts
Saturday, 7 November 2009
The Quest for XHTML Perfection
This afternoon I remembered the existence of the W3C Markup Validation Service, http://validator.w3.org/, and decided to submit the web sites I maintain. As usual I was appalled by the number of omissions, typing errors, and plain mistakes that your average browser will quite happily work round without telling you. Unterminated paragraph blocks, lists inside blocks, attribute values with a quote at one end but not the other, to name just three blunders which now no longer afflict my HTML.
The ideal is to press the Validate button and get back the message, "This document was successfully checked as XHTML 1.0 Strict!" Once you've got that, you're allowed to put a W3C badge on the page to tell the world how compliant you are, or at least the 0.1% or less of the world who've ever even heard of the W3C, or XHTML. Rather than confuse the other 99.9% of the world, I have decided not to use this badge. Also, I would then live in fear of inadvertently invalidating the page through some stupid edit, and incurring the wrath of the W3C.
Another reason for not boasting of my pages' compliance is that not all of them are, and there doesn't seem to be much I can do about it. At one of my sites, gratuitous link to encourage Google to notice it, I include a link to a specific page at the UK Charity Commission's web site. Even though I'm quoting their URL exactly, the W3C is flagging up errors in the URL and blaming me. This seems a mite pedantic of them. Am I supposed to tidy up someone else's web site?
The link in question is http://www.charity-commission.gov.uk/ShowCharity/RegisterOfCharities/CharityWithoutPartB.aspx?RegisteredCharityNumber=1119272&SubsidiaryNumber=0, and the presence of the ampersand near the end causes W3C to kick out four errors and three warnings. And now, by putting that link into this blog, I've managed to make this page non-compliant too!
Footnote: thinking about my question above, I wondered if I could tidy up the URL. Turns out I can leave the part from the ampersand onwards! I got lucky there, but I think my point still stands.
Now my only non-compliance is the use of the 'target' attribute in hrefs. Need to do a bit of research about why that's not valid XHTML.
The ideal is to press the Validate button and get back the message, "This document was successfully checked as XHTML 1.0 Strict!" Once you've got that, you're allowed to put a W3C badge on the page to tell the world how compliant you are, or at least the 0.1% or less of the world who've ever even heard of the W3C, or XHTML. Rather than confuse the other 99.9% of the world, I have decided not to use this badge. Also, I would then live in fear of inadvertently invalidating the page through some stupid edit, and incurring the wrath of the W3C.
Another reason for not boasting of my pages' compliance is that not all of them are, and there doesn't seem to be much I can do about it. At one of my sites, gratuitous link to encourage Google to notice it, I include a link to a specific page at the UK Charity Commission's web site. Even though I'm quoting their URL exactly, the W3C is flagging up errors in the URL and blaming me. This seems a mite pedantic of them. Am I supposed to tidy up someone else's web site?
The link in question is http://www.charity-commission.gov.uk/ShowCharity/RegisterOfCharities/CharityWithoutPartB.aspx?RegisteredCharityNumber=1119272&SubsidiaryNumber=0, and the presence of the ampersand near the end causes W3C to kick out four errors and three warnings. And now, by putting that link into this blog, I've managed to make this page non-compliant too!
Footnote: thinking about my question above, I wondered if I could tidy up the URL. Turns out I can leave the part from the ampersand onwards! I got lucky there, but I think my point still stands.
Now my only non-compliance is the use of the 'target' attribute in hrefs. Need to do a bit of research about why that's not valid XHTML.
Subscribe to:
Posts (Atom)