Browser support for the combined type, ID and class selectors?
A type selector matches the name of a document language element type. A type selector matches every instance of the element type in the document tree. For example:
/* The following rule matches all H1 elements
in the document tree: */
h1 { font-family: sans-serif; }
An ID selector matches an element instance based on its unique identifier.
/* The following rule matches the element whose
ID attribute has the value "header": */
#header { text-align: center; }
A class selector matches
/* The following rule matches all elements
with class "money": */
.money { color: green; }
Selectors can be combined in CSS:
h1#chapter1 { font-size: 32px; text-align: center }
p#chapter1.intro { text-align: left }
p.ending { font-style: italic; }
开发者_StackOverflow社区
#login.disabled { color: #f00; }
My question is, what is browser support (IE6 and up) for the combined type, ID, and class selector?
All your given selector combinations are supported in every browser in modern-day use. Including IE6+.
The only thing IE6 has trouble parsing is combined class selectors:
.class1.class2
which it reads as whichever class comes last in the chain (.class2
in this case), thereby causing it to match any element with at least that last class. An illustration can be found in this other answer.
The answers to this question: Combining a Class selector with an ID
...seem to indicate that #id.class does NOT work in IE6
精彩评论