Interview Questions

How do you target a certain browser?

CSS Interview Questions and Questions

(Continued from previous question...)

89. How do you target a certain browser?

IE can be targetted by preceding your properties with '* html'. For example...

#nav {
* html #nav { /* this will target IE */

Another way to target IE is with conditional comments. Put this (below) in the head - just before the closing tag - and put anything you want to be directed only at IE in another stylesheet.

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

If you need to target IE5x...

#wrap {
width:760px;   /* for IE5x */
w\idth:780px;   /* for all other major browsers */

(Continued on next question...)

Other Interview Questions