内部样式表中的HTML注释标签 [英] HTML Comments tags in internal stylesheet

查看:146
本文介绍了内部样式表中的HTML注释标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

在HTML文档中注释样式表以支持较旧的浏览器

我正在阅读Wrox发布的Professional ASP.NET 2.0。

I am reading Professional ASP.NET 2.0 published by Wrox. see below code.

    <head>
    <style type="text/css">

    <!--

    body {
    font-family:Verdana;
    }

    -->
    </style>
 </head>

以下几行来自本书:


包含HTML注释标记是因为并非所有浏览器都支持内部样式表。通常是较旧的浏览器不接受它们。将HTML注释放在样式定义周围会在非常老的浏览器中隐藏这些定义。

HTML comment tags are included because not all browsers support internal stylesheets.It is generally the older browsers that do not accept them. putting HTML comments around the style definitions hides these definitions from very old browsers.

现在我的问题是,内容之间如何可能注释只对旧浏览器隐藏而不对新浏览器隐藏?新浏览器不会受到评论的影响吗?

now my question is that how it is possible that contents between comments hides to only old browsers not to new ones? is new browsers not get affected by comments?

推荐答案

旧(或更旧的)浏览器无法识别< style> ,以便将其与其他任何未知元素一样对待,并将其内容视为HTML。该评论被视为评论,因此不会呈现任何内容。

Old (or rather, ancient) browsers do not recognise <style> so it gets treated like any other unknown element and its content is treated as HTML. The comment is treated as a comment, so nothing is rendered.

支持< style> 的浏览器将内容视为CSS并忽略HTML注释(按照规范)。

Browsers which support <style> know to treat the content as CSS and ignore the HTML comment (as per the specification).

这篇关于内部样式表中的HTML注释标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆