Summary
Of all the existing CSS methodologies I looked at, I took the most from BEM. There is much to appreciate in BEM:
- All elements get the same specificity; a class is added to all the elements.
- There is no use of type selectors so HTML structure isn't tightly coupled to the styles.
- It's easy to reason about what the parent of an element is, whether viewing the DOM tree in the browser developer tools or the CSS in a code editor.
However, the use of modifiers didn't really fit my needs. Although perhaps it wasn't preferable, my reality was that often I would need to override styles on a Block (in BEM parlance) depending upon some eventuality above it or by the side of it in the DOM.
For example, in the scenario where existing logic is already determined in an application, there may be a scenario where a class like contains2columns
would be added above the item in question in the DOM and I would need to style changes based upon that, as opposed to changes directly upon the...