Question

Usually HTML element attribute values are marked with a quotation mark, like


<input type="hidden" value="test" />

Sometimes, however, 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">

?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top