To pick up on Lawrence's comment, if you are working on a small site, you don't need full-on BEM naming. However, when working on large enterprise solutions, it helps to keep components discreet and self-contained. For example, I'm working on a large CMS with 4 other developers. Because we are all building separate components which can be authored in countless combinations, each needs to be contained to avoid CSS collisions. If we relied just on chained or contextual selector, we run into specificity issues very quickly.
Following your example, you risk ending up with selectors like .my-element.checked
, .this-box.checked
, .section .my-element.checked
and on and on. You get a lot of bloat and a lot of specificity. By using BEM, instead of .my-element.checked
(specificity of 20), you can just use .my-element--checked
(specificity of 10). This makes your code more modular and portable and eases the escalation of specificity -- which usually ends with someone getting frustrated and tossing in !important
.
That isn't to say that you should never use contextual selectors, just keep in mind the scope of the project and potential downfalls of both systems.
For your specific example, you might want to look at using the checked
attribute instead (or in addition if needed). If this is a form field, then <input type="checkbox" checked>
might actually be better. The attribute will help screen readers out and you can still style based on it:
input[type="checkbox"]:checked {color: green}