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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You have two options: (1) adding a specialized class in the HTML to the last row; or (2) using the
:last-childpseudo class in your CSS.Option 1: Specialized Class
If you can apply classes to your HTML, you can add a specialized class to the final row. If your markup is being generated by a server-side script (eg. a PHP script), you will need to edit that script to add similar markup.
HTML:
CSS:
Option 2: CSS Pseudo Class
The alternative is to use the
:last-childCSS pseudo class. Using the:last-childclass doesn’t require any changes to the HTML and so may be a better choice if you aren’t able to change the HTML. The CSS is almost identical to the above:CSS:
The drawback of this approach is that versions of Internet Explorer before 9 don’t support the
:last-childpseudo class.