Merin Nakarmi
Merin Nakarmi

Reputation: 3418

CSS for first td of each tr in certain table

I have table with id "student". e.g.

 <table id="student">
    <tr>
        <td>Role</td>
        <td>Merin</td>
        <td>Nakarmi</td>
    </tr>
    <tr>
        <td>Role</td>
        <td>Tchelen</td>
        <td>Lilian</td>
    </tr>
    <tr>
        <td>Role</td>
        <td>Suraj</td>
        <td>Shrestha</td>
    </tr>
</table>

For each row in this table, the first <td> has value Role and I want to hide this first <td> for every row. I tried option like

#student > tr > td:first-child
{ 
    width: 0px; important;
}

But unfortunately did not work.

Please help

Upvotes: 43

Views: 45056

Answers (3)

Code Lღver
Code Lღver

Reputation: 15603

Your this code is not correct:

{ width: 0px; important; }

this should be:

#student > tr > td:first-child{ 
  width: 0px !important; 
}

before important property you are using semicolon which is not correct.

Upvotes: 3

Venu immadi
Venu immadi

Reputation: 1605

 #student > tr > td:first-child{
  display : none;
    }

Upvotes: 2

Nitesh
Nitesh

Reputation: 15749

Use the below.

table#student tr td:first-child{display:none;}

WORKING DEMO

Upvotes: 83

Related Questions