Often some browsers display pages in a way we don’t like. To “teach” these browsers how to do things other browsers know we need to use tricks: “hacks”. Here are some common ones.
.class {//width:100px;}
.class {_width:100px;}
.class {\\width:100px;}
body:first-of-type .class { }
html:root*.class { }
html*.class { }
html[xmlns*=""] body:last-child { .class { }}
@media all and (min-width:0px) { body:last-child {.class { }}
body:last-child:not(:root:root) {.class { }}
@media screen and (-webkit-min-device-pixel-ratio:0){.class { }}
@-moz-document url-prefix() {.class { }}
.class, x:-moz-any-link { }
html:not([lang*=""]):not(:only-child) {.class { }}
html:not(:nth-child(1)) {.class { }}
Also we can use conditional comments to separate styles specific to Internet Explorer 6, 7, 8 from “main” styles. IE 6:
<!--[if IE 6]><link rel="stylesheet" type="text/css" href="ie6.css" /><![endif]-->
IE 7:
<!--[if IE 7]><link rel="stylesheet" type="text/css" href="ie7.css" /><![endif]-->
IE 8:
<!--[if IE 8]><link rel="stylesheet" type="text/css" href="ie8.css" /><![endif]-->
This blog is about things I encounter while doing web and non-web software development.