How to apply multiple css styles on single element

Discussion in 'CSS' started by maddyesign, Jul 3, 2010.

  1. #1
    If you like to apply multiple styles on the single element, all you have to do is separate the style names by a space.

    Lets say you have three classes

    .a {..}
    .b{..}
    .c{..}
    Code (markup):
    to apply them on a single div tag:

    <div class="a b c">
       .....
    </div>
    Code (markup):
     
    maddyesign, Jul 3, 2010 IP
  2. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #2
    And the purpose of the post is to what? Pad your post count?
     
    kk5st, Jul 3, 2010 IP
  3. andika.adi.s1

    andika.adi.s1 Peon

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I like to use multiple classes for things that I want to keep standard across the entire site. For example, if I always want the bottom-margin for elements that have a bottom-margin to be 10px. By creating a class that only encompases the botom-margin:10px; I can add it wherever it's needed.
     
    andika.adi.s1, Jul 5, 2010 IP
  4. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #4
    I would suggest you're not using the cascade part of cascading style sheets, and you're probably choosing your class tokens for presentation rather than semantic value. These are common afflictions suffered by the tyro. Experience and the desire to follow best practice are the cure.

    cheers,

    gary
     
    kk5st, Jul 5, 2010 IP