class = "ie" > Can we use this asclass="ie"<...">

Can we use this <body class = "all" <! - [if IE 7]> class = "ie" <! [Endif] - >>

Can we use this as <body class="all" <!--[if IE 7]>class="ie"<![endif]--> >?

I want to save all CSS in one file.

+3
source share
4 answers

You can use:

<body class="all">
  <!--[if ie]>
    <div class="ieOnly">
  <![endif]-->

<div id="content">

<p>...</p>

</div>

  <!--[if ie]>
    </div>
  <![endif]-->
</body>

Thus, the css selector for troubleshooting IE flaws / differences is more specific than regular

#content {/* for non-IE browsers */}

body.all .ieOnly #content {/* for IE */}

... and should override the 'normal' rules #contentand will never be applied by browsers other than IE, since the selector has an element .ieOnlythat is otherwise "invisible" to them.

, , ; , , .

+2

: ( , ), ?:)

body { } IE, :

<!--[if IE 7]>
  <link rel="stylesheet" type="text/css" href="ie7.css">
<![endif]-->

:

body { /* or body.all { */
  background: pink; /* Pink is pretty!, or green, whatever */
}
+2

No, you cannot accurately comment on an attribute even with conditional IE comments. But there may be other ways to express this.

+1
source

If you want to add a class to the browser-based body without hacks, you will need to use the server-side code and sniff UA.

+1
source

Source: https://habr.com/ru/post/1750215/


All Articles