Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS different color for table each line

I have this table with the following CSS formatting:

<table cellspacing="2">
    <tbody>
        <tr>
            <th>Name</th>                            
            <th>Area</th>                            
        </tr>
        <tr>
            <td>${it.conference}</td>                                              
            <td>${it.accepted}</td>                                      
        </tr>
    </tbody>
</table>

And CSS:

table {
    padding-left: 10px;
    width:90%;
    font-family:Arial, Helvetica, sans-serif;
    font-size:11px;
    text-align:left;
}

th, td {
    padding:5px 10px;
}

th {
    color:#666666;
    border-top:2px solid #b7ddf2;
    background-color:#ebf4fb;
}

How can i apply individual css modifications for each line (for example, I would like to change the color of 'Name', without messing up with the other lines formatting, which means, only modify that one. Is that possible to do?

like image 944
VictorArgentin Avatar asked Sep 05 '25 22:09

VictorArgentin


1 Answers

Are you looking for something similar to the nth-child CSS pseudo-class?

If you want a more fine grain control over each individual one you might want to consider applying classes to them and styling them differently.

Edit: Here are a few examples of nth-child.

like image 84
alexcoco Avatar answered Sep 11 '25 04:09

alexcoco