html 使用的内容类型正确吗?
我在我的网站上使用了 XHTML,但这完全破坏了 jQuery 及其插件。
因此,我想回到 html 4。我正在为我的 html 定义一些自定义属性,如下所示:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd" [
<!ATTLIST mytag myattribute CDATA #IMPLIED>
]>
这似乎是有效的 html,但是当我从服务器传递这样一个内容类型为 text/html 的页面时,我的浏览器显示“]>” - 它无法正确解析文档类型。
我应该使用不同的内容类型吗?
I was using XHTML on my website but that completely destroyed jQuery and its plugins.
Therefore, I want to go back to html 4. I am defining some custom attributes for my html, like so:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd" [
<!ATTLIST mytag myattribute CDATA #IMPLIED>
]>
This seems to be valid html for, but when I pass such a page from my server with a content type of text/html, my browser displays ']>' - it can't parse the doctype properly.
Is there a different content type I should be using?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自分开的列表
所以这基本上是行不通的。要使其正常工作,您需要复制所需服务器/本地计算机的 DTD,对其进行适当编辑并将其放在可公开访问的位置。请参阅文章了解更多详细信息。
就 jQuery 而言,如果您停止尝试按照自己的方式自定义 DTD,它应该可以正常工作。我不确定是否使用自定义 DTD,因为我从未这样做过,但仅将属性添加到元素而不是在 DTD 中定义它们不会导致 jq 出现问题。虽然该文档不会验证,但验证只是一种工具,在宏伟的计划中并不是太重要。
From A List Apart
So this basically isnt going to work. To get it to work you need to copy the DTD you want the server/local machine, edit it appropriately and put it in a publically accessible place. See the article for more detail.
As far as jQuery is concerned, it should work fine if you quit trying to customize the DTD in the fashion that you are. Im not sure about using a custom DTD as I have never done it, but just adding the attributes to the elements and not defining them in the DTD shouldnt cause a problem with jq. Granted the document wont validate, but validation is just a tool and not overly important in the grand scheme of things.