Francesco
Francesco

Reputation: 25239

select and set border on all td but the first one

i'm having hard time for a pretty silly simple task i need to add a border 1px on evey row, bu the first one...adding border to TR doesnt seem to work...

    <div id="container1"> 
        <table>
            <tr><td>1</td></tr>
            <tr><td>2</td></tr>
            <tr><td>3</td></tr>
            <tr><td>4</td></tr>
            <tr><td>5</td></tr>
        </table>
    </div>         
    <div id="container2"> 
        <table>
            <tr><td>1</td></tr>
            <tr><td>2</td></tr>
            <tr><td>3</td></tr>
            <tr><td>4</td></tr>
            <tr><td>5</td></tr>
        </table>
    </div> 

Upvotes: 0

Views: 3732

Answers (2)

silviubogan
silviubogan

Reputation: 3461

Note: in the title you say that you want to set a border to the td-s and in the question you say that you want to set a border to every row (a.k.a. tr). My examples set a border on the tr-s.

I hope one of these meets your needs:

tr:not(:first-child) {
    border: 1px solid red;
}

tr {
    border: 1px solid red;
}

#container1 tr:first-child {
    border: inherit;
}

Upvotes: 0

Litek
Litek

Reputation: 4888

try this:

td { border:1px solid black}
tr:first-child > td { border:none;}

Upvotes: 3

Related Questions