#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    111
    Rep Power
    12

    avoiding repetions in defining css classes


    Hi to all, & this is my question:
    say I have a css class such as:

    .classA1 { color: RED; font-weight: bold; font-size: 11px }

    Now I want to define other classes, that vary only in the font color, while everything else remains unchanged, for example:

    .classA2 = { color: GREEN; rest same as A1 }
    .classA3 = { color: BLUE; rest same as A1 }
    .classA4 = { color: YELLOW; rest same as A1 }

    How do I go about it, so I avoid having to repeat every time the same attributes? I know there is a way of defining a main class & then the variations (like for elements - a - a:hover - a:visited etc..) but I'm not sure how you do this...

    Thanks a lot for your help,

    Luca
  2. #2
  3. |<.+#f@#+.&.|
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Mar 2002
    Location
    norway
    Posts
    3,009
    Rep Power
    1224
    .classA1, .classA2, .classA3, .classA4 { font-weight: bold; font-size: 11px }
    .classA1 { color: RED;}
    .classA2 { color: GREEN;}
    .classA3 { color: BLUE; }
    .classA4 { color: YELLOW;}

    like this, with using the comma , to seperate the classes.


    for the other

    .main a:link {
    font-weight:bold;
    }

    will affect all links within the element with the class .main

    http://www.w3.org/TR/CSS21/selector.html

IMN logo majestic logo threadwatch logo seochat tools logo