Are single quotes valid in HTML/XHTML?
Asked Answered
S

3

29

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

<table width="100%">
<table width='100%'>
Sivie answered 5/2, 2010 at 21:8 Comment(1)
If ever again in doubt, you can have your document checked by validator.w3.org.Awn
F
23

Yes, single quotes are valid.

From the XML spec:

[10]   AttValue  ::= '"' ([^<&"] | Reference)* '"'
                  |  "'" ([^<&'] | Reference)* "'"
Firstling answered 5/2, 2010 at 21:11 Comment(0)
H
5

A source of confusion on this matter seems to come from this article,

http://www.javascriptkit.com/howto/xhtml_intro.shtml

which seems to claim that single quotes are not valid in xhtml. However, since no specification is cited, and since the article also claims that lowercase names for attributes and elements are forbidden, the author may merely be expressing an editorial prohibition against using single quotes.

Hordein answered 11/4, 2010 at 0:16 Comment(0)
S
4

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.

Sigurd answered 5/2, 2010 at 21:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.