views:

81

answers:

3

I understand the need for &, <, etc. But is " necessary? I suppose it could be useful inside tag attributes, but inside the text, outside any tag, is it necessary?

A: 

Certainly not necessary, your HTML will validate just fine without it.

However, if your HTML is generated and includes user input in unknown text encodings, or if you’re supplying HTML to people who might not serve it with the correct text encoding, then you might want to err on the safe side and encode any slightly odd-looking character as an entity.

Paul D. Waite
"then you might want to err on the safe side and encode any slightly odd-looking character as an entity." Won't ASCII work the same practically everywhere?
Javier Badia
*"if your HTML is generated and includes user input in unknown text encodings..."*
Anon.
I’m thinking of the fancier quote characters: “ and ” (“ and ”). They’re not included in ASCII, and I think the old Windows text encoding that you sometimes get in Word documents has them at another set of code points. I’ve had them display funny on web pages made by people copying content from Word documents.But for the regular quotes (", which I believe is actually the double prime symbol used for inches) yeah, I think you’re fine.
Paul D. Waite
Yes, I mean the regular quotes.
Javier Badia
+1  A: 

No, it is not necessary when used in normal html content.

for escaping quotes in tag attributes you can use " or either \" or \' depending on which you want to escape.

santosc
A: 

No, it's not. As an example, the specifications for HTML 4.01 (http://www.w3.org/TR/1999/REC-html401-19991224/charset.html#h-5.3.2) state:

[...] authors may use SGML character references.

That 'may' implies you are not forced to use them.

klez