<div class="sidebar"> <a class="button"> ... </a> </div> <!-- about --> <div class="about"> <a class="button"> ... </a> </div> .button { display: inline-block; color: red; border: 1px solid black; font-size: 28px; font-weight: bold; } .about { .button { font-size: 14px; } } Tuesday, June 18, 13 But we’re not on a smaller site, and we’re working with a team of other developers. So the next day, you pull down the latest code and find another developer on your team, working on a completely separate page, put in some CSS code like this. Now, we can see what he was trying to do. He wanted to re-use your button class, but he found that your original .button class was defining a font-size to big for what he needed. He knew your .button class was already being used, so instead of fixing that, and potentially breaking your page, he said to himself “well most of the styles that I need are in .button, so I’m just going to override the one style I have a problem with, and it’ll be fine.” I’m sure many of you have seen or done this a thousand times because I know I have. And initially, this doesn’t seem like a bad idea at all. It certainly resolves the issue for the short term. The real headache is if you’re in the habit of doing these simple overrides, and compound that over hundreds of templates of a large site, you’re going to end up with a big mess of CSS classes that only work under specific contexts, in this case, the button’s parent. In the code above, the .button class works one way usually, except when maybe it’s under an .about class. And then in the contact page, it could be changed to be 18px. Then some different way on some other page. These overrides all build on themselves, and the real frustration comes in later when you try to make an innocent change in one place, perhaps in the DOM itself, and then find you’ve broken a bunch of styles that relied on some hidden context, get frustrated, and hate yourself. Ultimately, the cause is that we’re not treating the .button class as a re-usable style. This is because it’s trying to do too much initially, and we’re trying to fix that problem by overriding.