How To Properly Name Css Classes
How To Properly Name Css Classes
_georgemoller
HOW TO
PROPERLY
NAME CSS
CLASSES
George Moller
_georgemoller
01 BEM METHODOLOGY
BEM
Block Modifier
e.g
e.g
.btn {
/*...*/
Element .btn--primary {
/*...*/
} e.g
}
.btn__icon {
/*...*/
}
George Moller
_georgemoller
02 BLOCK
A block is an element that is meaningful on it’s own.
George Moller
_georgemoller
03 ELEMENT
Elements are always parts of a block and have no standalone
meaning.
04 MODIFIER
Think of the modifier as a flag used to change the appearence,
behavior or state.
.block--modifier
George Moller
_georgemoller
Does this nested block make sense on it’s own? if so, write it as a reusable block.