Hi,
I'm trying to decide the best approach to implementing the majority of CSS styles on my page. The 2 approaches I have recognized are:
1) To attach a class attribute to most elements and style each class like so:
fieldset.MyForm { }
legend.MyForm { }
2) To attach class attributes to container elements and style nested elements like so:
.MyForm fieldset { }
.MyForm legend { }
From my experimentation with both approaches:
1) seems more accurate, with less chance of unwanted inheritances or having to overrule existing classes to get a style working but since styles aren't shared I need to continually redefine them.
2) is more elegant from a backend perspective, as I don't need to define class attributes everywhere, but sometimes requires me to define .Classes .Of .Increasing .Depth to overrule existing styles due to CSS specificity.
What is the better approach in terms of code readability/scalability/maintainability? Is there another, better approach I haven't identified?
Thanks