views:

587

answers:

2

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 "?

+4  A: 

' is not part of the HTML standard.

" is, though, so is fine to use.

Anon.
+5  A: 

If you look at the list of HTML 4 character entities, ' isn't on it. That's why it shouldn't be used. 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.

Basically some browsers don't understand XML/XHTML so they rely on them falling back to trying to interpret it as HTML and ' is not a valid HTML symbol.

Edit: As noted in comments and the other answer, " is fine (see the list of references link above).

cletus
`"` is on the list though, so should be OK.
Bennett McElwee