In Nicolas Gallaghers' write up about HTML semantics, he outlines a method of structuring html and css in a modular way (influenced by the BEM architecture). He gives an example, which I don’t completely understand:
/* Utility */
.u-utilityName {}
/* Component */
.ComponentName {}
/* Component modifier */
.ComponentName--modifierName {}
/* Component descendant */
.ComponentName-descendant {}
/* Component descendant modifier */
.ComponentName-descendant--modifierName {}
/* Component state (scoped to component) */
.ComponentName.is-stateOfComponent {}
- First, what I don’t understand is: what is the difference between a utility and a component?
- And where does the difference in notation between these two come from (the utility classname is prefixed with a “u-”)?
- Last; what is the difference between a state and a modifier (they both have separate notation)?
He does not explain this in depth in his article, and I would still like to understand. So I hope someone can answer this.