The Curse of '

by Charles Miller on July 1, 2003

(Issue ROL-216)

Dear Roller maintainers. ' is not a valid HTML entity reference. The definitive list of HTML entity references is here, and ' is not on it.

' was introduced as a standard entity in XML, and thus is also standard in XHTML. Even if you are using XHTML, if you wish to produce web-pages that are backwards compatible with browsers that do not support XHTML (and IE is one of them), you should avoid '.

If you're desperate, you can use ' instead. (See also: the backwards-compatibility section of the XHTML standard)

Even if you're serving valid XHTML with an XML DOCTYPE, there is still significant controversy as to whether user-agents should handle it as XML unless it is also served with the text/xml MIME-type (which would cause IE to display the page as a parse-tree)

Most of the time, it is fine to leave apostrophes unescaped in XML. XML's escaping rules are such that if some character's meaning is unambiguous, it need not be escaped. For example, if you have the tag <foo>, you only need to escape it as &lt;foo>. By just escaping the less-than sign, you make the meaning of the greater-than unambiguous, and therefore it need not be escaped itself. Since apostrophes have no special meaning outside of tags, they need not be munged in regular text.

As an aside, it's amusing to see IE penalised for following the standard. :)

Previously: From the Hyperbole to the Ridiculous

Next: A Social Hack for Online Polls