Skip to content

Instantly share code, notes, and snippets.

@daphnesmit
Last active July 8, 2024 14:53
Show Gist options
  • Save daphnesmit/d2d77f1b54bf2f176a30426607994bc0 to your computer and use it in GitHub Desktop.
Save daphnesmit/d2d77f1b54bf2f176a30426607994bc0 to your computer and use it in GitHub Desktop.
Why is BEM preferred over BEEEEEEEEEM

Why is BEEEEEEM Not Preferred Over BEM?

BEM (Block, Element, Modifier) is a widely adopted naming convention in web development, especially for CSS, because it provides a clear, maintainable, and scalable methodology for naming and structuring CSS classes. The convention breaks down the user interface into independent blocks, elements within those blocks, and modifiers that alter the appearance or behavior of those blocks or elements.

BEEEEEEM, which stands for Block, Element, Element, Element, Element, Element, Modifier, suggests a much more nested and complex structure. Here are several reasons why BEEEEEEM is not preferred over BEM:

Complexity and Readability

  • BEM: block__element--modifier (e.g., button__icon--large)
  • BEEEEEEM: block__element__element__element__element__element--modifier

The BEM convention is straightforward and easy to read. In contrast, BEEEEEEM's excessive nesting can make class names long, cumbersome, and hard to understand.

Maintainability

Deeply nested structures (as implied by BEEEEEEM) can make the CSS harder to maintain. Changes in deeply nested elements often require updates across multiple places, increasing the risk of errors and inconsistencies.

Performance

Long class names and highly specific selectors can impact CSS parsing performance in the browser. BEM encourages minimal and flat class structures, which are more performance-friendly.

Scalability

As a project grows, using an excessively nested naming convention like BEEEEEEM can become unmanageable. BEM's simpler structure scales more effectively for large codebases.

CSS Specificity

BEM helps manage CSS specificity in a predictable way, reducing the need for overly specific selectors and !important rules. BEEEEEEM, with its potential for deep nesting, might lead to higher specificity that complicates overrides and debugging.

Best Practices

Industry standards and best practices generally favor BEM for its balance between structure and simplicity. BEEEEEEM deviates from this balance, introducing unnecessary complexity without substantial benefits.

In summary, BEM is preferred over BEEEEEEM because it promotes simplicity, readability, maintainability, performance, and scalability in CSS development. Excessively nested structures, as suggested by BEEEEEEM, tend to introduce more problems than they solve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment