Should I encode quotes (such as " and ' -> ”
and ’
) in my HTML body (e.g. convert <p>Matt's Stuff</p>
to <p>Matt’s Stuff</p>
)? I was under the impression I should, but a co-worker said that it was no big deal. I'm dubious but I can't find anything that says it is forbidden. Am I mistaken? Is it a best-practice to encode? Or is it simply useless?
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a way to play audio on a mobile browser w
- HTML form is not sending $_POST values
- implementing html5 drag and drop photos with knock
-
Why does the box-shadow property not apply to a
Typicaly such isn't necessary unless you're placing such values into a tag's attribute (or other places where having quote marks would throw off parsing). In regular body text un-encoded will work fine.
If you want your markup to be parsable as XML, you'll want to encode the following:
Definitely do this in attributes whether you're trying to make your code XML compliant or not.
Encoding quotation marks (") is in practice only needed if the're inside an attribute, however for the HTML code to be correct (passing HTML validation), you should always encode quotation marks as
"
.Apostrophes (') don't need escaping in HTML. In XHTML they should be encoded as
'
.No, you only need to use character references for quotes (single or double) if you want to use them inside an attribute value declaration that uses the same quotes for the value declaration:
Both title values are
The sign says "Matt's Stuff"
.