Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are Single Quotes Valid in a Doctype?

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

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'>

Also, does the same hold true for XML doctypes?

<?xml version='1.0' encoding='utf-8'?>
like image 220
brad Avatar asked Jan 11 '10 21:01

brad


1 Answers

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.

like image 75
molf Avatar answered Sep 18 '22 15:09

molf