Are single quotes valid in HTML/XHTML?

Viewed 3702

Are single quotes valid in HTML? And more specifically: XHTML strict.

<table width="100%">
<table width='100%'>
3 Answers

Yes, single quotes are valid.

From the XML spec:

[10]   AttValue  ::= '"' ([^<&"] | Reference)* '"'
                  |  "'" ([^<&'] | Reference)* "'"

According to the spec, both are valid :-)

[9]    EntityValue    ::=    '"' ([^%&"] | PEReference | Reference)* '"'  
   |  "'" ([^%&'] | PEReference | Reference)* "'" 
[10]    AttValue    ::=    '"' ([^<&"] | Reference)* '"'  
   |  "'" ([^<&'] | Reference)* "'" 
[11]    SystemLiteral    ::=    ('"' [^"]* '"') | ("'" [^']* "'")  
[12]    PubidLiteral    ::=    '"' PubidChar* '"' | "'" (PubidChar - "'")* "'"

And the W3C-Validator accepts it as well.

Related