Programming CSS
Jeremy Keith
2394

I think that when you say:

if (condition1 && condition2) {
// code here
}
Well, that’s what the decendant selector does:
condition1 condition2 {
// styles here
}

You are more close to having 2 clases together than the descendant selector. When you have 2 classes together you are checking for 2 conditions and both conditions need to be true. Right?

Because in the descendant selector I think we could map it more like this:

if (condition1) {
 if (condition2) {
 // code here
 }
}

I mean, at the end is the same result, and I think we can “simplify” the second to the first, but the problem is that if we work with && we are working within statements/expressions and with the if we work with nesting, we have more clarity of what is working outside of that. I mean CSS works parsing the DOM, so I think that the descendant selector is more like:

So we have parsed 2 times the whole DOM. And I think that && does not shows us the correct complexity of that.

I agree with your main idea: that CSS selectors are really powerfull. But I think your article could be an oversimplification and, in order to prove your point, you could actually had explain this :D