tags:

views:

36

answers:

1

I have a variable number of table rows (n), and I would like the border bottom to apply to rows 0..(n-1)

how do I do that?

+3  A: 

If you can apply classes to your markup, add a specialized class to the final row n.

markup:

<table>
   <tr>
      <td>
      </td>
   </tr>
   <tr>
      <td>
      </td>
   </tr>
   <tr class="last">
      <td>
      </td>
   </tr>
</table>

CSS:

table
{
   border-collapse:collapse;
}
td
{
   border-bottom: 1px solid #000;
}
.last td
{
   border-bottom: none;
}

Your other option is to use the :last-child CSS selector but IE doesn't support it.

KP
I have a variable number of rows. So, I have no idea when the last row is. =\
DerNalia
@DerNalia, if you have a dynamic number of rows you've got a server-side, or client-side, script generating them. I'd suggest tagging the question with that language that so that we can help you implement @KP's first suggestion. As `:last-child {border-bottom: 0 none transparent;` (or similar) is the only pure-css option.
David Thomas
aight, thats fair.
DerNalia