Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jun 2007
    Posts
    61
    Thanks
    13
    Thanked 0 Times in 0 Posts

    CSS - additional rule for specific internal tag

    I want to create a style rule (class) and give it in the <TABLE> tag (e. g. <TABLE CLASS="blah">. But whenever there is a <TD> in the table, I want an additional rule for the td (e. g. give a border to that td, but not to each element in the td, or any other element in the table), without having to write another class and then do <TD CLASS="blah1">. This is to avoid typing multiple <TD CLASS="blah1"> with each cell and therefore to cut down on HTML cource code.

    So my HTML would look like:

    Code:
    <TABLE CLASS="blah">
       <TR>
          <TD>something
          </TD>
       </TR>
       <TR>
          <TD>something
          </TD>
       </TR>
    </TABLE>
    instead of
    Code:
    <TABLE CLASS="blah">
       <TR>
          <TD CLASS="blah1">something
          </TD>
       </TR>
       <TR>
          <TD CLASS="blah1">something
          </TD>
       </TR>
    </TABLE>
    Does anyone have any idea how I write the style sheet? I tried this:

    .blah,
    .blah a: link,
    .blah a: visited
    { primary rules }
    td.blah: { additional rule for td }

    but it does not work.

    Thank you very much for your time!

  • #2
    Regular Coder Jutlander's Avatar
    Join Date
    Jun 2007
    Location
    In my own sick little world :P
    Posts
    425
    Thanks
    1
    Thanked 12 Times in 12 Posts
    How about just:

    Code:
    td {
    border: 1px solid #555;
    }
    .
    .

  • #3
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    table.blah td {additional rules}
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #4
    New Coder
    Join Date
    Jun 2007
    Posts
    61
    Thanks
    13
    Thanked 0 Times in 0 Posts
    Hi _Aerospace_Eng_ and Jutlander

    Thank you for your time! I did something pretty close:

    Code:
    .blah td {additional rule for td }
    ...which worked. Thank you again!

  • #5
    Regular Coder Jutlander's Avatar
    Join Date
    Jun 2007
    Location
    In my own sick little world :P
    Posts
    425
    Thanks
    1
    Thanked 12 Times in 12 Posts
    Just FYI, you did the same as Aero suggested, except for writing 'table' before the period. This is optional whether you want to do that or not, I do it too because it makes it easier to keep track of classes and ID's.
    .
    .


  •  

    Posting Permissions

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