SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Issue with table td class overriding..

    I'm trying to apply a class to a td to have it's contents right-aligned:

    HTML Code:
    <table class="basic_form">
      <tr>
       <td class="right">blah</td>
     </tr>
    </table>
    However, it doesn't seem to be taking effect and the only conclusion I can draw is that the table class 'basic_form' is overriding it? (even though it comes before the 'right' class in my .css?

    CSS:
    Code:
    /* TABLES */
    .basic_form{
    	margin: 0 0 25px 0; 
    	padding: 0px;
    	font-family: Verdana, Arial, Helvetica, sans-serif;
    	font-size: 12px;
    	color: #424242; 
    }
    .basic_form td, .basic_form th{
    	padding: 0 10px 18px 0;
    	vertical-align:top;
    	text-align: left;
    }
    
    
    /* CLASSES */
    .right{
    	text-align: right;
    }
    
    
    /* the following works but I don't think I should need to? */
    td.right, th.right{
    	text-align: right;
    }


    Can anyone shed some light on why this is occuring?

  2. #2
    Winemaster bronze trophy BonRouge's Avatar
    Join Date
    Oct 2004
    Location
    Sendai, Japan
    Posts
    2,417
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think '.basic_form td' is more specific than '.right'. Your solution is a good one - it makes it more specific. Another way would be to use '.basic_form .right'.

  3. #3
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  4. #4
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep, .basic_form td is more specific.

    Cheers guys.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •