CSS中的HTML注释? [英] HTML comments in CSS?

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

问题描述

我查看了一些亚马逊的CSS,发现他们有HTML评论出了一大堆CSS。我知道有HTML评论的Internet Explorer的条件格式,但我在 Chrome 中查看。它的目的是什么?

I was checking out some of Amazon's CSS and noticed they have HTML commented out a chunk of CSS. I know there is conditional formatting for Internet Explorer with HTML comments, but I am viewing this in Chrome. What is the purpose of it?

哦,我应该注意到这些样式实际上正在应用。

Oh, I should note that these styles are actually being applied.

<!-- BeginNav -->

<style type="text/css">

    <!--

    .nav-sprite {
      background-image: url(http://g-ecx.images-amazon.com/images/G/01/gno/beacon/BeaconSprite-US-01._V141013396_.png);
    }
    .nav_pop_h {
      background-image: url(http://g-ecx.images-amazon.com/images/G/01/gno/beacon/nav-pop-h._V155853593_.png);
    }
    .nav_pop_v {
      background-image: url(http://g-ecx.images-amazon.com/images/G/01/gno/beacon/nav-pop-v._V155853593_.png);
    }
    .nav_ie6 .nav_pop_h {
      background-image: url(http://g-ecx.images-amazon.com/images/G/01/gno/beacon/nav-pop-8bit-h._V155961234_.png);
    }
    .nav_ie6 .nav_pop_v {
      background-image: url(http://g-ecx.images-amazon.com/images/G/01/gno/beacon/nav-pop-8bit-v._V155961234_.png);
    }
    .nav-ajax-loading .nav-ajax-message {
      background: center center url(http://g-ecx.images-amazon.com/images/G/01/javascripts/lib/popover/images/snake._V192571611_.gif) no-repeat;
    }
    -->

</style>


推荐答案

使用不能识别< style> 标签的浏览器。

It's created by someone who thought that visitors of the site use a browser which does not recognise <style> tags.

< style> 标签,将不会因为HTML注释而显示奇怪字符(CSS规则)。

(Ancient) browsers, which do not recognise <style> tags, will not show "weird" characters (CSS rules) because of the HTML comments.

大多数浏览器都会识别< style> 标记,因此开发人员似乎使用<! - - > 出了(坏)习惯。应使用。

Most browsers recognise the <style> tag, so the developer seems to use <!-- --> out of (bad) habit. It should not be used.

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

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