On Jan 23, 2006, at 4:37 PM, Paul Kahl wrote:
> Is it possilble to do something like this:
>
> .clsBold {font-weight: bold;}
> .clsItalic {font-style: italic;}
> .clsRed {color: #F00;}
>
> .clsTitleDiv {clsBold; clsItalic; clsRed;}
>
> In other words, can I call a previously defined class inside
> another class,
> in some fashion, thus saving me time and code?
>
> I already know that I can stack classes inside a tag in this
> fashion: [div
> class="clsX clsY clsZ"][/div]. That's not really what I'm looking
> for. I'm
> looking for something that is handled purely inside the stylesheet.
> I'm
> hoping there's a greater way to do re-usability.
>
> ~Paul Kahl
Paul,
I'm afraid that you can't define blocks of CSS rules the way you
described above. The closest thing would be more along these lines:
.clsBold, .clsTitleDiv { font-weight: bold; }
.clsItalic, .clsTitleDiv { font-style: italic; }
.clsRed, .clsTitleDiv { color: #F00; }
In this case, you get .clsTitleDiv sharing the same declarations as
above without a separate rule. In general, however, I'd advise
against spreading out a definition of a class like this unless it
makes sense for it to inherit from multiple (mostly orthogonal) rules.
As far as reusability goes in general, just make sure to keep your
classes meaningful ("error" instead of "clsRed", for instance) and
use a consistent style throughout your markup, and your CSS should be
svelte. I rarely find that I'm repeating myself in CSS, other than
perhaps reusing color values (across borders, backgrounds, and actual
text color) and occasionally sizes. For these things, CSS-SSC might
be a good tool if you're concerned about the way repetition can
impact maintainability:
http://www.shauninman.com/plete/2005/08/css-constants
--
Matthew Levine, (http://www.infocraft.com/)
______________________________________________________________________
css-discuss [EMAIL PROTECTED]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/