If I have a container and a list of item, I might have the following HTML markup:
<div class="container food foodcontainer">
<ul class="list foodlist">
<li class="listitem fooditems"></li>
...
And I can style them two ways (assuming using plain CSS and not less/sass or any other helpers). First, like one normally would do:
.food { /* style */ }
.food .list { /* style */ }
.food .list .listitems { /* style */ }
Or, I can simply reference everything by a verbose, descriptive class name:
.foodcontainer { /* style */ }
.foodlist { /* style */ }
.fooditems { /* style */ }
No more cascading relationships! Is there a reason not to do this for everything (such that every element is referenced by a single class/id name)? I (and people working on the same codebase) simply do not find either to be that much better in readability; if anything, we find unique and direct names easier to grasp and also easier to search for.
There was an ancient article that generally recommended shorter, more unique selectors, for performance; in its more recent update, it's said that overall the performance has changed for the better. But how much better? Is the shorter way still faster?
.food .list) is more flexible and my personal preference. This is the reason for the "C" in CSS. You want your styles to cascade, as it makes it easier to apply broad global styles without having to rewrite the same properties for similar classes multiple times. You could do.classone, .classtwobut why? If they're that similar and contain the same styles, it's just duplicate styling.intwith 5 states but MAX_INT possible memory states, it should probably be anenum. Similarly, in your second example, what doesclass="container foodcontainer"(nofood) mean? The CSS will screw up massively, but it's only working with the completely valid HTML classes it was given.