What is the difference between these two selectors?
.classA.classB {
border: 1px solid;
}
.classA .classB {
border: 1px solid;
}
What is the difference between these two selectors?
.classA.classB {
border: 1px solid;
}
.classA .classB {
border: 1px solid;
}
A style like this is far more common, and would target any type of element of class "classB" that is nested inside any type of element of class "classA".
It would work, for example, on:
This one, however, targets any type of element that is both class "classA", as well as class "classB". This type of style is less frequently seen, but still useful in some circumstances.
This would apply to this example:
However, it would have no effect on the following:
(Note that when an HTML element has multiple classes, they are separated by spaces.)
.classA.classB
refers to an element that has both classes A and B (class="classA classB"
); whereas.classA .classB
refers to an element withclass="classB"
descended from an element withclass="classA"
.Edit: Spec for reference: Attribute Selectors (See section 5.8.3 Class Selectors)