BEM (Block, Element, Modifier) is a methodology for structuring CSS and HTML code. It aims to avoid name collisions, keep specificity low, and make code more maintainable. Key principles include:
1. Using a naming convention of block-name__element-name--modifier to identify components, their parts, and variants.
2. Organizing CSS and HTML files by component in a flat directory structure to locate code easily.
3. Avoiding global selectors and name prefixes to prevent unintended side effects.
4. Keeping selectors shallow and specificity low to allow flexible overriding without !important declarations.