views:

142

answers:

1

As stated in this question, single quotes in html has either become more popular or we have begun to notice them more often.

Regardless, I have a related question. The HTML 4.01 Strict doctype as shown at w3schools (below) uses double quotes.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd"&gt;

As stated in the accepted answer, single quotes are perfectly valid. However, the quoted values in the doctype aren't necessarily attributes so are single quotes permitted? In other words, is the following a valid doctype? Furthermore, if this is valid HTML, is it accepted by modern browsers?

<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01//EN'
    'http://www.w3.org/TR/html4/strict.dtd'&gt;

Also, does the same hold true for XML doctypes?

<?xml version='1.0' encoding='utf-8'?>
+5  A: 

Yes, both are valid.

See the SGML spec. At some point while drilling through all links for the doctype declaration, you'll end up at the "system identifier" specification (the parts containing quotes), which is defined as:

( lit , "
system data [45] ,
lit ) | "
( lita ,    '
system data [45] ,
lita )  '

The definition syntax is weird, but it appears that either single or double quotes are allowed (it's similar to the attribute values definition).

A doctype with single quotes also seems to validate just fine.

molf
And the same in the XML spec: http://www.w3.org/TR/REC-xml/#NT-SystemLiteral
bobince