BEM naming convention
CSS & HTML classes use the BEM convention for their naming convention
This blog 1 explains it well
BEM convention¶
B block
E element
M modifier
combined:
These are all class names for an HTML element
Renaming breaks JavaScript¶
To prevent the site breaking when renaming classes without knowing you have to rename in JavaScript , explicitly start class names with js-*
if referenced in JavaScript.
A Philosophy of Software Design: Non explicit references can lead to complex code
Spaces in class name¶
A class name can’t have spaces. A space-separated string in your class
attribute, gives your element several classes.
Backlinks¶
- pure CSS content toggle study
- note it uses BEM naming convention