单引号在Doctype中是否有效?

时间:2021-08-21 22:29:39

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

正如这个问题所述,html中的单引号要么变得更受欢迎,要么我们已经开始更频繁地注意它们。

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

无论如何,我有一个相关的问题。 w3schools(下面)中显示的HTML 4.01 Strict doctype使用双引号。

<!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中的引用值不一定是属性,因此允许单引号?换句话说,以下是有效的doctype吗?此外,如果这是有效的HTML,它是否被现代浏览器接受?

<!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 doctypes也是如此吗?

<?xml version='1.0' encoding='utf-8'?>

1 个解决方案

#1


10  

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:

请参阅SGML规范。在钻取doctype声明的所有链接的某个时刻,您将最终得到“系统标识符”规范(包含引号的部分),其定义为:

( 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.

带单引号的doctype似乎也很好。

#1


10  

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:

请参阅SGML规范。在钻取doctype声明的所有链接的某个时刻,您将最终得到“系统标识符”规范(包含引号的部分),其定义为:

( 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.

带单引号的doctype似乎也很好。