html 使用的内容类型正确吗?

发布于 2024-11-29 06:36:40 字数 384 浏览 6 评论 0原文

我在我的网站上使用了 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 技术交流群。

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

发布评论

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

评论(1

要走就滚别墨迹 2024-12-06 06:36:40

来自分开的列表

如果您通过 W3C 验证器运行这样的文件,您会发现它
验证得非常好。如果您下载了此示例文件
文章并验证文件internal.html,你可以看到这个
你自己。不幸的是,当您在浏览器中显示该文件时,
]>显示在屏幕上。没有办法解决这个错误,所以这个
方法是正确的。

所以这基本上是行不通的。要使其正常工作,您需要复制所需服务器/本地计算机的 DTD,对其进行适当编辑并将其放在可公开访问的位置。请参阅文章了解更多详细信息。

就 jQuery 而言,如果您停止尝试按照自己的方式自定义 DTD,它应该可以正常工作。我不确定是否使用自定义 DTD,因为我从未这样做过,但仅将属性添加到元素而不是在 DTD 中定义它们不会导致 jq 出现问题。虽然该文档不会验证,但验证只是一种工具,在宏伟的计划中并不是太重要。

From A List Apart

If you run such a file through the W3C validator, you find that it
validates wonderfully well. If you download the sample files for this
article and validate file internal.html, you can see this for
yourself. Unfortunately, when you display the file in a browser, the
]> shows up on the screen. There’s no way around this bug, so this
approach is right out.

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.

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