Results 1 to 4 of 4

Thread: Table not to use its parent CSS - Help

  1. #1
    Join Date
    Aug 2007
    Location
    MO USA
    Posts
    106
    Thanks
    37
    Thanked 0 Times in 0 Posts

    Default Table not to use its parent CSS - Help

    I have a html page with a parent CSS. This CSS has styles for table, tr and td. All tables, tr's and td's gets its style from this CSS file. Now i have a (nested) table within the html and i dont want the parent CSS style to apply the style to this table and its contents. How do i apply a new CSS style only for this Table and its TR, TD?

    The problem i face now is this table is getting its style from the parent CSS. I tried putting an ID for this table and creating new styles like "#table_id table{}" but it doesnt seem to work. It still uses the parent CSS.

    Please Help. Thanks.

  2. #2
    Join Date
    Sep 2008
    Location
    Whiteford, MD
    Posts
    39
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Default

    Assign the table an ID and then referance all the first tables CSS under the first table, e.g. table#one and then do table#two for the second. Make sure all descendants of the first table have table#one.

  3. #3
    Join Date
    Aug 2007
    Location
    MO USA
    Posts
    106
    Thanks
    37
    Thanked 0 Times in 0 Posts

    Default

    Can you please post with a small example code (html and css)? Would the CSS look something like this -

    table #one td{}
    table #two td{}

    Thanks

  4. #4
    Join Date
    Sep 2008
    Location
    Whiteford, MD
    Posts
    39
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Default

    Sure

    Say you have this HTML

    Code:
    <table id="one">
    <tr>
    <td><!--Crap here-->
    </td>
    </tr>
    </table>
    And you have a second table

    Code:
    <table id="two">
    <tr>
    <td><!--HOLY CRAP, MORE STUFF-->
    </td>
    </tr>
    </table
    You would need this CSS

    Code:
    table#one td {
      /*Styles here*/
    }
    table#two td {
      /*More styles here*/
    }
    HTH.

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
  •