Skip to main content

CSS Naming Conventions

CSS naming conventions play a crucial role in making your code organized, maintainable, and easy to understand. This tutorial will guide you through popular methodologies like BEM, OOCSS, and SMACSS to help you write clean and maintainable CSS.

BEM (Block, Element, Modifier)

BEM is a popular naming convention that stands for Block, Element, and Modifier. It provides a clear structure for your CSS classes and makes it easy to understand the relationships between components.


A block is a standalone entity that represents a high-level component in your design.

/* Block example */
.header {


An element is a part of a block that has no standalone meaning and is semantically tied to its block.

/* Element example */
.header__logo {
.header__navigation {


A modifier is a flag on a block or element that represents a different state or variation.

/* Modifier example */
.header--fixed {
.header__logo--small {

OOCSS (Object-Oriented CSS)

OOCSS is a methodology that encourages you to think of your CSS as a collection of reusable objects. It focuses on separating structure (layout) from skin (visual appearance) to promote reusability and maintainability.

/* OOCSS example */
/* Structure */
.box {

/* Skin */
.box--red {
background-color: red;
color: white;

SMACSS (Scalable and Modular Architecture for CSS)

SMACSS is a CSS architecture that aims to make your CSS more maintainable and scalable by categorizing your styles into five types: Base, Layout, Module, State, and Theme.

/* SMACSS example */
/* Base */
p {

/* Layout */
.l-container {

/* Module */
.m-button {

/* State */
.is-active {

/* Theme */
.t-dark {


Using a consistent naming convention is essential for keeping your CSS organized and maintainable. By adopting a methodology like BEM, OOCSS, or SMACSS, you can write clean, easy-to-understand code that scales well with your projects.