CSS is often mistaken for something easy in Web Development, but it requires quite a bit of skill to master. Even after almost 10 years of working with CSS, I’m learning new approaches, handy tips, and tricks to create even leaner code.
Something I often see overlooked by up-and-coming front-end developers, is consistent naming conventions in their code and in their CSS. That’s why I today will cover my approach to naming CSS classes and IDs.
Using consistent naming conventions in your CSS code has several benefits, including:
BEM is a popular naming convention for CSS that is widely used by developers. The naming convention is a system for naming classes in a way that promotes modularity and consistency. Here’s a brief explanation of each part of the BEM naming convention:
Using BEM as a naming convention for your CSS code can make your code more readable, maintainable, and modular. The system also makes it easier to collaborate with other developers and avoid naming conflicts.