Why shouldn't `'` be used to escape single quotes?

brad picture brad · Jan 18, 2010 · Viewed 235.7k times · Source

As stated in, When did single quotes in HTML become so popular? and Jquery embedded quote in attribute, the Wikipedia entry on HTML says the following:

The single-quote character ('), when used to quote an attribute value, must also be escaped as ' or ' (should NOT be escaped as ' except in XHTML documents) when it appears within the attribute value itself.

Why shouldn't ' be used? Also, is " safe to be used instead of "?

Answer

cletus picture cletus · Jan 18, 2010

" is on the official list of valid HTML 4 entities, but ' is not.

From C.16. The Named Character Reference ':

The named character reference ' (the apostrophe, U+0027) was introduced in XML 1.0 but does not appear in HTML. Authors should therefore use ' instead of ' to work as expected in HTML 4 user agents.