Which of the following is a correct BEM naming pattern?

Prepare for the CSS Mastery Recipient Portal Test. Study with comprehensive questions and in-depth explanations. Enhance your CSS skills and ace your test!

Multiple Choice

Which of the following is a correct BEM naming pattern?

Explanation:
BEM naming uses a Block__Element--Modifier pattern. The block is a standalone component, the element is a part of that block, and the modifier describes a variation or state. The correct form shows the block name, two underscores, the element name, two dashes, and the modifier. For example, card__title--highlight means the title element of a card with the highlight variation. This structure keeps CSS organized and predictable, clarifying which piece of a component you’re styling and which variant you want. Other patterns don’t fit BEM: some use a single dash to separate parts, some use two underscores for the modifier, which isn’t how modifiers are expressed in BEM. The chosen pattern cleanly distinguishes block, element, and modifier, aligning with the standard convention.

BEM naming uses a Block__Element--Modifier pattern. The block is a standalone component, the element is a part of that block, and the modifier describes a variation or state. The correct form shows the block name, two underscores, the element name, two dashes, and the modifier. For example, card__title--highlight means the title element of a card with the highlight variation. This structure keeps CSS organized and predictable, clarifying which piece of a component you’re styling and which variant you want.

Other patterns don’t fit BEM: some use a single dash to separate parts, some use two underscores for the modifier, which isn’t how modifiers are expressed in BEM. The chosen pattern cleanly distinguishes block, element, and modifier, aligning with the standard convention.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy