Are single quotes valid in HTML/XHTML?

前端 未结 3 1903
陌清茗
陌清茗 2020-12-07 00:18

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

相关标签:
3条回答
  • 2020-12-07 00:47

    Yes, single quotes are valid.

    From the XML spec:

    [10]   AttValue  ::= '"' ([^<&"] | Reference)* '"'
                      |  "'" ([^<&'] | Reference)* "'"
    
    0 讨论(0)
  • 2020-12-07 00:49

    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.

    0 讨论(0)
  • 2020-12-07 01:01

    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.

    0 讨论(0)
提交回复
热议问题