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
You could also have table > thead > tr and then table > tbody > tr. So you might need to specify whether you want the first row from the thead or the tbody. find('tr:first') will select the tr in the thead. – Jeff S.
With <tr> tag In this CSS :first-child example, the first row (ie: the first <tr> tag) will have a yellow background color. All other rows in the table will not be styled by the :first-child selector.
This can be achieved using :nth-of-type() instead of :nth-child() , as the former only considers elements of the same type when calculating their indices. Note though that both :nth-child() and :nth-of-type() are only supported in IE9 and above.
The ::first-line selector is used to add a style to the first line of the specified selector. Note: The following properties can be used with ::first-line: font properties.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With