如何阻止 HTML Tidy 删除我的结束标签?

发布于 2024-07-19 06:17:29 字数 311 浏览 4 评论 0原文

目前 HTML Tidy 正在更改任何空 HTML 标签并将它们组合成一个,例如:

<script src="somescript.js"></script>

变成:

<script src="somescript.js" />

这是一个问题,因为在我的 HTML 的“head”中包含 javascript 文件现在在某些明确需要此结束标签的浏览器中不起作用与开始标签分开。

如何阻止 Tidy 删除这些结束标签?

Currently HTML Tidy is changing any empty HTML tag and combining them into one, for example:

<script src="somescript.js"></script>

Turns into:

<script src="somescript.js" />

This is a problem because including javascript files in the "head" of my HTML is now not working in some browser that explicitly need this closing tag to be separate from the opening tag.

How can I stop Tidy from removing these closing tags?

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

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

发布评论

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

评论(2

无敌元气妹 2024-07-26 06:17:29

尝试在

Try sticking some content inside the <script> element, content that won't upset the browser, but which will prevent Tidy from collapsing the tags. Something like whitespace, or a  , or a javascript comment.

滴情不沾 2024-07-26 06:17:29

您是否为 HTML 定义了 DOCTYPE?

将关闭标签包装到单个标签中应该适用于有效的 Xhtml,但可能会扰乱旧的 html。

Have you defined a DOCTYPE for your HTML?

Wrapping the close tag into a single tag should work for valid Xhtml, but might upset ye olde html.

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