Are apostrophes valid containers for HTML element attribute values?
Usually HTML element attribute values are marked with a quotation mark, like
<input type="hidden" value="test" />
Sometimes, howe开发者_StackOverflowver, you see code like
<input type='hidden' value='test' />
Is it valid HTML and can it cause any problems? What about mixing the two, like
<input type='hidden' value="test">
?
The linked question from James Allardice's comment to my original question lead me to the answer: yes, apostrophes are valid containers for HTML element attribute values.
Specification: On SGML and HTML
By default, SGML requires that all attribute values be delimited using either double quotation marks (ASCII decimal 34) or single quotation marks (ASCII decimal 39). Single quote marks can be included within the attribute value when the value is delimited by double quote marks, and vice versa.
精彩评论