What is BEM methodology in CSS?
Instruction: Explain the Block Element Modifier (BEM) methodology and its significance.
Context: This question evaluates the candidate's understanding of BEM, a naming convention for classes in HTML and CSS, intended to make the front-end code more readable and maintainable.
Updated
Official answer available
Read the opening below, then unlock the full answer and practical guidance.
BEM organizes component names around a block, its elements and modifiers. In the common double-underscore/double-hyphen convention, card is a block, card__title is an element and card--featured is a modifier.
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS example</title> <style> .card { padding: 1rem; border: 1px solid #555; } .card__title { margin-top: 0; } .card--featured...
Related Questions
-
easy
-
easy
-
easy
-
medium
-
medium
-
medium