Internet Explorer versions up to and including 6 exhibit the star HTML selector bug. This is a bug in which the selectors that should fail, don’t fail. A descendant selector, such as " * html ", shouldn’t match any elements,because the html element is the top-most parent element and,therfore, it can’t be a descendant of any other element. However, Internet Explorer versions 5.5 and 6 ignore the universal selector at the beginning of this selector.
When you compose a rule with the * html selector. This constitutes valid CSS, but it shouldn’t match any elements because the selector should apply the rule to any html element that’s the descendant of any other element and, since html is the root element, hence it’s never a descendant of any other element. However, while most other browsers ignore it, Internet Explorer 5.5 and 6 will interpret this selector as if there was no universal selector, like the rule below:
When you compose a rule with the * html selector. This constitutes valid CSS, but it shouldn’t match any elements because the selector should apply the rule to any html element that’s the descendant of any other element and, since html is the root element, hence it’s never a descendant of any other element. However, while most other browsers ignore it, Internet Explorer 5.5 and 6 will interpret this selector as if there was no universal selector, like the rule below:
html {
/*declarations*/
}
/*declarations*/
}
As a result of the above bug existing in IE5.5 and 6 we do sometimes use this bug as a hack for IE5.5 and 6 called as the star selector hack. The star selector hack is a safe way of applying CSS rules to Internet Explorer 5.5 and 6 without affecting other browsers.
You’d use it like this:
You’d use it like this:
.topbox {
color:red;
}
* html .topbox{
color:blue;
}
color:red;
}
* html .topbox{
color:blue;
}
Only Internet Explorer 6 and earlier versions will apply the latter rule and set the color to blue, other browsers will ignore it.
Find out below the selectors and their interpretation by Internet Explorer 6 and lower versions :
Selector | Internet Explorer'sInterpretation |
* html | html |
* * body | * body |
*html body | html body |