picayunish said:
Toby A Inkster wrote in news
[email protected]:
Why using so many classes instead of one.
In this case as a frivilous example, but there are some cases where the
ability to assign multiple classes to one element comes in handy. For
example:
<style>
.male { color: blue; }
.female { color: #f88; }
.deceased { text-decoration: strike-through; }
.alive { font-weight: bold; }
.british { list-style: url('flag-uk.png'); }
.french { list-style: url('flag-fr.png'); }
.german { list-style: url('flag-de.png'); }
.spanish { list-style: url('flag-es.png'); }
</style>
<ul id="peoplelist">
<li class="male alive british">Toby</li>
<li class="deceased german">Hans</li>
<li class="female alive french">Isabelle</li>
<li class="male spanish">Jose</li>
<!-- etc -->
</ul>
In this example, a person can be male, female or unspecified; deceased,
alive or unspecified; and British, French, German, Spanish or unspecified.
If I was going to create individual styles for each possible combination,
eg:
..maleAliveBritish { color: blue; font-weight: bold; list-style:
url('flag-uk.png'); }
then there would be 3*3*5=45 classes needed, bloating the style sheet and
making it less manageable (e.g. if I wanted to change the .female colour,
I would have to change it in 15 places!)
So here it is a good idea to assign multiple classes to a single element.