Welcome to %s forums

<No. 1 Community for developers, by developers/>

Login Register

How to add html class for just only internet explorer?

For general web development questions using HTML and CSS.
Post Reply
admin
Site Admin
Posts: 45

How to add html class for just only internet explorer?

Post by admin » Thu Aug 22, 2019 2:36 pm

Code: Select all

<!--[if IE ]>
   <body class="ie">
<![endif]-->
<!--[if !IE]>-->
   <body>
<!--<![endif]-->
Now you can write IE specific styles in a regular stylesheet, by prefacing the CSS selectors with


.ie


Or more robust version putting class on HTML element:

Code: Select all

<!DOCTYPE html>
<!--[if IEMobile 7 ]> <html dir="ltr" lang="en-US"class="no-js iem7"> <![endif]-->
<!--[if lt IE 7 ]> <html dir="ltr" lang="en-US" class="no-js ie6 oldie"> <![endif]-->
<!--[if IE 7 ]>    <html dir="ltr" lang="en-US" class="no-js ie7 oldie"> <![endif]-->
<!--[if IE 8 ]>    <html dir="ltr" lang="en-US" class="no-js ie8 oldie"> <![endif]-->
<!--[if (gte IE 9)|(gt IEMobile 7)|!(IEMobile)|!(IE)]><!--><html dir="ltr" lang="en-US" class="no-js"><!--<![endif]-->

Post Reply