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 3 of 3
  1. #1
    New Coder
    Join Date
    Oct 2003
    Location
    UK
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Table header problem

    I am trying to use CSS to colour the background of certain table header cells, only the ones I want coloured though.

    Everything I have tried colours all my header cells..ouch !


    Table code:
    Code:
    <tr>
    <th>Example1</th>
    <th>Example2</th>
    <th>Example3</th>
    <th>Example4</th>
    <th>Example5</th>
    <th>Example6</th>
    </tr>
    My CSS:
    Code:
    BODY {
    	color: #111111;
    	background-color: White;
    	font-family: "Arial Narrow", sans-serif;
    	font-size: medium;
    	font-style: italic;
    	text-align: justify;
    }
    
    h1{
    	border: dotted #DC143C;
    }
    
    }
    
    TH{
    	background-color: green;
    
    }

  • #2
    Senior Coder
    Join Date
    Feb 2003
    Location
    Ontario, Canada
    Posts
    1,223
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You have an extra } in your CSS, for one.

    Secondly, you need a way to select specific cells. A class, for example:

    Code:
    <th class="first">This one is first</th>
    <th>This one is normal</th>
    <th>This one is normal</th>
    Then:

    Code:
    th.first { background-color: #f00; }
    That will give the th with a class of "first" a red background, and the others will remain the default colour (white, most likely).

  • #3
    New Coder
    Join Date
    Oct 2003
    Location
    UK
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Great

    Just what I wanted, sorry about the extra braces, I added that part in a hurry to show what I had tried.


  •  

    Posting Permissions

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