gpt4 book ai didi

html - 如何在 HTML 源代码中注释 HTML 标记属性?

转载 作者:技术小花猫 更新时间:2023-10-29 11:53:59 25 4
gpt4 key购买 nike

例如:

<a /*title="need to be comment out"*/>a link</a>

最佳答案

W3C documentation建议无法完成:

Note that comments are markup.

这基本上意味着 <!-- ...>评论标签就像任何其他标签一样,所以 <a <!--title="need to be comment out"-->>a link</a><a <span></span>>a link</a>一样错误.

为了快速破解,我相信一个常见的选择是重命名该属性。当您获得无效的 HTML 时,您可以暂时删除该属性:

<a xtitle="need to be comment out">a link</a>

如果你碰巧使用的是服务器端语言,你也可以使用它自己的注释语法。例如,在 PHP 中你可以这样做:

<a <?php/*title="need to be comment out"*/?>>a link</a>

... 生成此 HTML:

<a >a link</a>

... 并在 ASP.NET 中你可以使用 <%-- Comment goes here --%>ASP.NET MVC Razor语法是 @* Comment goes here *@ .

关于html - 如何在 HTML 源代码中注释 HTML 标记属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4744353/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com