html – 为样式表创建有效的条件注释,而不会出现“伪造注释”验证器错误

html – 为样式表创建有效的条件注释,而不会出现“伪造注释”验证器错误,第1张

概述我的头标记中有以下内容: <link rel="stylesheet" href="Scripts/styleMain.css" media="all" type="text/css" /><![if gte IE 9]><!--><link rel="stylesheet" href="Scripts/styleMob.css" media="screen and (max-width:50 我的头标记中有以下内容:

<link rel="stylesheet" href="Scripts/styleMain.CSS" media="all" type="text/CSS" /><![if gte IE 9]><!--><link rel="stylesheet" href="Scripts/styleMob.CSS" media="screen and (max-wIDth:500px)" type="text/CSS" /><link rel="stylesheet" href="Scripts/styleDes.CSS" media="screen and (min-wIDth:501px)" type="text/CSS" /><!--<![endif]--><!--[if lt IE 9]><link rel="stylesheet" href="styleDes.CSS" type="text/CSS" /><![endif]-->

问题是,第二行被认为是虚假评论,而同一行上的第二个标记被认为是评论的过早结束.

在同一行上添加额外的标签,并在第一个endif上给我两个假的评论错误.

有什么方法可以让我的样式表有条件,并让他们验证?或者我注定要在我的OCD编码中使用无效的代码?

解决方法 你的第二行在错误的地方有开头的评论分隔符:

<!--[if gte IE 9]><!-->

请注意,此处的语法突出显示它现在正确地突出显示为注释.

随后的标记的其余部分也将正确突出显示,因为<! - >现在被视为<!接着是 - >,而不是<! - 后跟>就像你的无效标记一样:

<link rel="stylesheet" href="Scripts/styleMain.CSS" media="all" type="text/CSS" /><!--[if gte IE 9]><!--><link rel="stylesheet" href="Scripts/styleMob.CSS" media="screen and (max-wIDth:500px)" type="text/CSS" /><link rel="stylesheet" href="Scripts/styleDes.CSS" media="screen and (min-wIDth:501px)" type="text/CSS" /><!--<![endif]--><!--[if lt IE 9]><link rel="stylesheet" href="styleDes.CSS" type="text/CSS" /><![endif]-->

您的代码中没有突出显示为注释的位将是IE9及其他浏览器以及其他浏览器将如何看到您的标记.较旧的IE只会看到您的第一个和最后一个< link>元素.

总结

以上是内存溢出为你收集整理的html – 为样式表创建有效的条件注释,而不会出现“伪造注释”验证器错误全部内容,希望文章能够帮你解决html – 为样式表创建有效的条件注释,而不会出现“伪造注释”验证器错误所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1067773.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存