DEV Community

Salvietta150x40
Salvietta150x40

Posted on • Originally published at ma-no.org

Introduction to Bem (Block Element Modifier)

I think I might not be the only one with this experience: after finally grasping all the important concepts regarding CSS I wanted to start giving what I thought would be beautiful yet simple style to my HTML code. But suddenly I ended up with class names such as “blue” “bigger” “text_normal”. “text_normal2” and similar. I stumbled directly into this CSS pitfall, which seems to be caused by a lack of structure and rules to follow when writing CSS. This kind of code is dangerous and hard to maintain because you might forget what class name does what and to which HTML element it can be applied, and so on. Chaos reigns.

So what possible solutions to this problem are there? You could come up with your own “home-made” CSS-naming set of rules to keep your code manageable but this would mean only you would be able to read the code fast and your team members would have to try and decipher your rule set. Not to say if everyone in the team made up their own CSS naming convention. Why not try an option that has been around some time know and therefor is tried and tested?

Read all

Top comments (0)