Skip to content

Instantly share code, notes, and snippets.

@hamishrouse
Last active August 11, 2021 21:07
Show Gist options
  • Save hamishrouse/f85c77c59b9c86b51a81f84a1b680dbd to your computer and use it in GitHub Desktop.
Save hamishrouse/f85c77c59b9c86b51a81f84a1b680dbd to your computer and use it in GitHub Desktop.
CSS Naming Conventions

CSS Naming Convention

BEM

Button Example

Block:

.button {}

Element:

.button__label {}

Modifer:

.button--large {}

Extending BEM: Namespaces

Object Type: .o-[name]

.o-button {}

Component Type: .c-[name]

.c-gallery {}

Theme Type: .th-[name]

.th-dark {}

Utility Type: .u-[name]

.u-text-caps {}

Javascript Hook: .js-[name]

.js-gallery {}

Testing Hook: .ts-[name] / .qa-[name]

.ts-gallery {}

Is/Has States: .is-[name] / .has-[name]

.is-selected {}
.has-added {}

Further Resources: https://csswizardry.com/2015/08/bemit-taking-the-bem-naming-convention-a-step-further/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment