I know when there is a space in between, it will look for the class on the right within the class on the left.
.classA .classB {
...
}
However, what does it look for when there is no space?
.classA.classB {
...
}
I know when there is a space in between, it will look for the class on the right within the class on the left.
.classA .classB {
...
}
However, what does it look for when there is no space?
.classA.classB {
...
}
The first example (space-separated classes) is a parent-child relationship. .classB
is found inside .classA
.
<div class="classA">
<div class="classB"></div>
</div>
The second is for one element with multiple classes, like so:
<div class="classA classB"></div>
Very different situations, but both extremely useful!
Further reading here:
css select an element with 2 class
http://css-tricks.com/multiple-class-id-selectors/
It's used when you need an element, with both classes.
<div class="classA classB"></div>
would match
.classA.classB{}
See also:
http://css-tricks.com/multiple-class-id-selectors/
In the first example .classA .classB
you're selecting elements with the class classB
that are descendants of elements that have classA
.
In the second example .classA.classB
you're selecting elements that have both classes classA
and classB
.