Today I was told by a client that my method of writing HTML & CSS is very complicated, and that he prefers the method used by the joomla template guys at rockettheme, the problem here is that I am under the impression that all the books and all the articles that I read about CSS tell me to write CSS in the following manner:
- Assign id’s and classes to elements on the page, where each class is a group for certain types of elements
- Assign styles to the elements using their id’s and classes.
Simple, right?
Now the client suggests to use a different method, where you:
- Assign visual styles to certain classes.
- Give elements these classes.
Here is a simplified example using the clients suggested idea:
.box1 {
background:red;
}
.box2 {
background:green;
}
.box3 {
background:blue;
}
.title1 h3 {
background:black;
color:white;
}
.title2 h3 {
background:white;
color:black;
}
.title3 h3 {
background:orange;
color:white;
}
Using this CSS the client can have up to 9 different boxes!
<div class="box1 title1">
<h3>some heading</h3>
<p>some text</p>
</div>
<div class="box1 title2">
<h3>some heading</h3>
<p>some text</p>
</div>
<div class="box1 title3">
<h3>some heading</h3>
<p>some text</p>
</div>
<div class="box2 title1">
<h3>some heading</h3>
<p>some text</p>
</div>
<div class="box2 title2">
<h3>some heading</h3>
<p>some text</p>
</div>
<div class="box2 title3">
<h3>some heading</h3>
<p>some text</p>
</div>
<div class="box3 title1">
<h3>some heading</h3>
<p>some text</p>
</div>
<div class="box3 title2">
<h3>some heading</h3>
<p>some text</p>
</div>
<div class="box3 title3">
<h3>some heading</h3>
<p>some text</p>
</div>
To do the same using my method, to add more boxed you need to edit more CSS and is generally harder to work with and modify he argues.
.box1,
.box4,
.box7 {
background:red;
}
.box1 h3,
.box4 h3,
.box7 h3 {
background:black;
color:white;
}
.box2,
.box5,
.box8 {
background:green;
}
.box2 h3,
.box5 h3,
.box8 h3 {
background:white;
color:black;
}
.box3,
.box6,
.box9 {
background:blue;
}
.box3 h3,
.box6 h3,
.box9 h3 {
background:orange;
color:white;
}
<div class="box1">
<h3>some heading</h3>
<p>some text</p>
</div>
<div class="box2">
<h3>some heading</h3>
<p>some text</p>
</div>
<div class="box3">
<h3>some heading</h3>
<p>some text</p>
</div>
<div class="box4">
<h3>some heading</h3>
<p>some text</p>
</div>
<div class="box5">
<h3>some heading</h3>
<p>some text</p>
</div>
<div class="box6">
<h3>some heading</h3>
<p>some text</p>
</div>
<div class="box7">
<h3>some heading</h3>
<p>some text</p>
</div>
<div class="box8">
<h3>some heading</h3>
<p>some text</p>
</div>
<div class="box9">
<h3>some heading</h3>
<p>some text</p>
</div>
While I argue that his method means that to edit a box, he would need to edit all of the boxes that need to be changed on all the pages, he says that it’s not a problem because server side scripting handles that.
So considering my method is indeed longer, , and while my clients method really looks like the very commonly seen “clear” class or the “clear-right” class that clears an element, and seems similar to the “redbg”,“bluebg” classes, I could not make any good arguments for my method or convince him that it was wrong to have classes like “clear”.
Could someone help me understand if the clients method has any major drawbacks or benefits or is his way of writing CSS better than mine?
So that I can decide what kind of CSS to continue writing.