单引号在文档类型中有效吗?

发布于 2024-08-18 05:27:47 字数 907 浏览 3 评论 0原文

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

无论如何,我有一个相关的问题。 HTML 4.01 Strict 文档类型如 w3schools 所示(如下) 使用双引号。

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

正如接受的答案中所述,单引号完全有效。但是,文档类型中的带引号的值不一定是属性,因此是否允许使用单引号?换句话说,以下内容是有效的文档类型吗?此外,如果这是有效的 HTML,现代浏览器是否接受它?

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

另外,对于 XML 文档类型也是如此吗?

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一抹淡然 2024-08-25 05:27:47

是的,两者都有效。

请参阅SGML 规范。在钻取文档类型声明的所有链接时,您最终会到达“

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

定义语法很奇怪,但似乎单引号或双引号都是允许的(与属性值定义类似)。

带单引号的文档类型似乎也可以验证

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文