Set css style only in the first row of the table

How to access the first row of a CSS table with a different class name tr .

 <div id="right"> <table> <tbody> <tr class="head"> <td >Date</td><td>Info</td><td>More</td> </tr> <tr><td>...</td></tr></table> </div> 

How to make this css

 #right table tr:first-child td:first-child { border-top-left-radius: 10px; } #right table tr:first-child td:last-child { border-top-right-radius: 10px; } 

applies only to .head

+4
source share
4 answers
 #right .head td:first-child{ border-top-left-radius: 10px; } #right .head td:last-child { border-top-right-radius: 10px; } 
+3
source

You can do it further.

 #right tr:first-child td:first-child { background-color: red; } 

Select the first tr and then the first td.

+1
source

use the :first-child pseudo :first-child to get the first element.

how

 #right .head td:first-child { border-top-left-radius: 10px; } #right .head td:last-child { border-top-right-radius: 10px; } 
0
source
 #right table tr.head td:first-child { border-top-left-radius: 10px; } #right table tr.head td:last-child { border-top-right-radius: 10px; } 
0
source

Source: https://habr.com/ru/post/1502606/


All Articles