[thelist] Nesting CSS Classes...Why??

Marc Seyon seyon at delime.com
Sun Mar 3 11:53:01 CST 2002


Message from Bob Boisvert (3/2/2002 11:42 PM)

>What is the need of a second class if it inherits the attributes of the
>first?.  Both classes have a font-weight but only the weight of the first is
>used disregarding the second (the way it reads in the book, seems like a
>typo).

Nesting classes is not so different to nesting HTML elements to create a
block of text within other text that you want styled differently, for
example, emphasised, or bolded. When you apply this second style, you only
change certain properties, letting the rest be inherited.

So for example if you've got
P
{
font-face: verdana;
color: red;
}

chances are you won't repeat these in your B tag... you'd just do
B
{
font-weight: bolder;
}

>Is nesting CSS classes a common practice? and what's a good example
>of why a designer would use this?.

....hypothetically, if you've got black text, but part of your site has a
black background... you could use a class="blackbg", eg <div class="blackbg">

Then have your elements respond to that by changing text colour to white,
possibly by using another class.

>  Is it pointless to nest the classes if one inherits the others attributes

If it inherits all the properties identically, yeah probably is kinda
pointless...

hope that helps.

regards.
-marc



More information about the thelist mailing list