basic CSS help with repeating values.

Discussion in 'CSS' started by fadetoblack22, Jun 16, 2008.

  1. #1
    Say I had the following 2 classes. How would I make it so subinfo2 would use all the values from subinfo with just a change in width?

    .subinfo {
    width: 877px;
    height: 200px;
    text-align: left;
    padding: 3px;

    .subinfo2 {
    width: 900px;
    height: 200px;
    text-align: left;
    padding: 3px;
     
    fadetoblack22, Jun 16, 2008 IP
  2. KatieK

    KatieK Active Member

    Messages:
    116
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    58
    #2
    Here's what I'd do:

    
    .subinfo, .subinfo2
       {   width: 877px;
            height: 200px;
    	text-align: left;
    	padding: 3px;
    	}
    
    .subinfo2
      {  width: 900px; }
    
    Code (markup):
     
    KatieK, Jun 16, 2008 IP
    fadetoblack22 likes this.
  3. fadetoblack22

    fadetoblack22 Well-Known Member

    Messages:
    2,399
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    160
    #3
    thanks :)

    I'm guessing the 900px will override the 877px?
     
    fadetoblack22, Jun 17, 2008 IP
  4. KatieK

    KatieK Active Member

    Messages:
    116
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    58
    #4
    Precisely - since the other width declaration is listed second, it will override the first. That's the cascade part of cascading style sheets. :)
     
    KatieK, Jun 17, 2008 IP
  5. fadetoblack22

    fadetoblack22 Well-Known Member

    Messages:
    2,399
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    160
    #5
    thanks :) I didn't think about that.
     
    fadetoblack22, Jun 17, 2008 IP