Javier
Javier

Reputation: 4623

Is it necessary to use character entities for quotes in HTML?

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?

Upvotes: 0

Views: 349

Answers (3)

Federico klez Culloca
Federico klez Culloca

Reputation: 27119

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.

Upvotes: 0

santosc
santosc

Reputation: 1273

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.

Upvotes: 2

Paul D. Waite
Paul D. Waite

Reputation: 98796

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.

Upvotes: 0

Related Questions