Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a list of browser conditionals for use including stylesheets?

I've seen people doing things like this in their HTML:

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

Does this work across all modern browsers and is there a list of browser types that will work with that kind of if statement?

Edit

Thanks Ross. Interesting to find out about gt, lt, gte, & lte.

like image 926
Mark Biek Avatar asked Sep 05 '08 15:09

Mark Biek


2 Answers

This works across all browsers because anything except IE sees <!--IGNORED COMMENT-->. Only IE reads the comment if it contains a conditional clause. Have a look at this article

You can also specify which version of IE. For example:

<!--[if IE 8]>
<link rel="stylesheet type="text/css" href="ie8.css" />
<![endif]-->
like image 70
Ross Avatar answered Oct 20 '22 22:10

Ross


If you can use Javascript, there are several options:

navigator.appName
navigator.appVersion 

link

Or something more robust by using a library such as jQuery.

Finally, you could use the BrowserDetect object from QuirksMode.

Once you have the browser name and version, you can then insert HTML to link to a style sheet or include other tags.

like image 2
sock Avatar answered Oct 20 '22 20:10

sock