- Code: Select all
[b]IE 6 and below[/b]
* html {}
[b]IE 7 and below[/b]
*:first-child+html {} * html {}
[b]IE 7 only[/b]
*:first-child+html {}
[b]IE 7 and modern browsers only[/b]
html>body {}
[b]Modern browsers only (not IE 7)[/b]
html>/**/body {}
[b]Recent Opera versions 9 and below[/b]
html:first-child {}
Usage
If you want to add 5px padding to a div element called #comments specifically for IE 7, then you can use the following hack:
- Code: Select all
*:first-child+html #comments
{
padding: 5px;
}
But if you want to apply the padding just for IE 6, then the following will do the trick:
- Code: Select all
* html #comments
{
padding: 5px;
}
Note that CSS Hacks are not recommended due to their dependence on browser bugs and therefore they should only be used as the last resort.