单引号在文档类型中有效吗?
如这个问题中所述,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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,两者都有效。
请参阅SGML 规范。在钻取文档类型声明的所有链接时,您最终会到达“
定义语法很奇怪,但似乎单引号或双引号都是允许的(与属性值定义类似)。
带单引号的文档类型似乎也可以验证。
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:
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.