Browser Specific CSS For Your Website

To provide a browser specific CSS for different browser, you need to use a browser specific CSS. On this blog post i am going to provide you some important browser specific css code. A bowser specific CSS code can be a media query, selector or certain syntax construction that is read only by a certain browser.

Bellow you will find examples of browser specific CSS code for some different browser.

/* IE6 */
#id_name { _color: blue}

/* IE6, IE7 */
#id_name { *color: blue; /* or #color: blue */}

/* Everything but IE6 */
#id_name { color/**/: blue}

 /* IE6, IE7, IE8 */
#id_name { color: blue\9;}

 /* IE7, IE8 */
#id_name { color/*\**/: blue\9;}

 /* IE6, IE7 -- acts as an !important */
#id_name { color: blue !ie;}

/* string after ! can be anything */

Browser Specific Selector CSS

/* IE6 and below */
* html #id_name  { color: red } 

/* IE7 */
*:first-child+html #id_name { color: red } 

/* IE7, FF, Saf, Opera  */
html>body #id_name { color: red }

/* IE8, FF, Saf, Opera (Everything but IE 6,7) */
html>/**/body #id_name { color: red }

/* Opera 9.27 and below, safari 2 */
html:first-child #id_name { color: red }

/* Safari 2-3 */
html[xmlns*=""] body:last-child #id_name { color: red }

/* safari 3+, chrome 1+, opera9+, ff 3.5+ */
body:nth-of-type(1) #id_name { color: red }

/* safari 3+, chrome 1+, opera9+, ff 3.5+ */
body:first-of-type #id_name {  color: red }

/* saf3+, chrome1+ */
@media screen and (-webkit-min-device-pixel-ratio:0) {
 #diez  { color: red  }
}

/* iPhone / mobile webkit */
@media screen and (max-device-width: 480px) {
 #id_name { color: red  }
}

/* Safari 2 - 3.1 */
html[xmlns*=""]:root #id_name  { color: red  }

/* Safari 2 - 3.1, Opera 9.25 */
*|html[xmlns*=""] #id_name { color: red  }

/* Everything but IE6-8 */
:root *> #id_name { color: red  }

/* IE7 */
*+html #id_name {  color: red }

/* Firefox only. 1+ */
#id_name,  x:-moz-any-link  { color: red }

/* Firefox 3.0+ */
#id_name,  x:-moz-any-link, x:default  { color: red  }

Note:- You can see more about browser specific css hack through this link http://browserhacks.com/

Leave a Reply