Why does BEM often use two underscores instead of one for modifiers?

前端 未结 5 1870
梦如初夏
梦如初夏 2021-01-31 18:26

In BEM, I understand that with modifiers, two dashes makes sense so that you can distinguish the modifier in my-block-my-modifier with my-block--my-modifier

5条回答
  •  离开以前
    2021-01-31 18:53

    According to BEM naming convention, single underscore has two other usages,

    1. The modifier name is separated from the block or element name by a single underscore (_).
    2. The modifier value is separated from the modifier name by a single underscore (_).

    So for separating element name from the block name is done by a double underscore.

    The element name is separated from the block name by a double underscore (__).

提交回复
热议问题