rahularyansharma rahularyansharma - 1 month ago 9
CSS Question

Give second or fourth column right side border using css in Internet Explorer

I just want to give second and fourth

<td >
right side border ...

as you can see I have following table:

<table class="secondtd">
<tr>
<td> Name </td>
<td> Class </td>
<td> RollNo </td>
<td> Batch </td>
</tr>
</table>


I have tried something like this in css

.secondtd td+td {
border-right:solid 1px red;
}


but not work for me .. I am using IE .

Answer

You could assign the class two the 2nd and 4th element of the tables:

 <td class="secondborder"> </td>

Or you could use nth-child:

td:nth-child(2), td:nth-child(4) {
 border-right:thick double #ff0000;
}

http://jsfiddle.net/ekHQf/

Which would select the 2nd and 4th element. If you only have 4 td's you could use even:

td:nth-child(even) {
  border-right:thick double #ff0000;
}

http://jsfiddle.net/ekHQf/1/

Edit:

From the comments to do this with a class applied:

.secondtd td:nth-child(2) {
  border-right:thick double #ff0000;
}