简体   繁体   中英

CSS for first td of each tr in certain table

I have table with id "student". eg

 <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

Use the below.

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

WORKING DEMO

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM