Is there a difference between these?
.someClass.anotherClass
.someClass .anotherClass
Does the white space make a difference. If yes, what difference does it make?
Is there a difference between these?
.someClass.anotherClass
.someClass .anotherClass
Does the white space make a difference. If yes, what difference does it make?
Yes it makes a difference. Using a space is the descendant selector. In your example,
anotherClass
must be a descendant ofsomeClass
.Without a space, you are targeting elements that match all classes specified. In your example, matched elements must have both
someClass
andanotherClass
..someClass.anotherClass will select below element
.someClass .anotherClass (descendant selector)
.someClass.anotherClass will work in the case of if your class name is "someClass anotherClass", Means you have only one class including space between name.
.someClass .anotherClass It will not affect to your first class['someClass'] code if you have two different classes. Only second class with be affected.
Hope u will get the point.