Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

?

like image 400
simon Avatar asked Oct 11 '22 03:10

simon


1 Answers

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.

like image 164
simon Avatar answered Oct 17 '22 19:10

simon