tags:

views:

302

answers:

2

I tried :

.bb (
    border-bottom:1px;
)

<tr class="bb">

But no effect at all.

+3  A: 

Try the following instead:

<html>
 <head>
  <title>Table row styling</title>
  <style type="text/css">
    .bb td, .bb th {
     border-bottom: 1px solid black !important;
    }
  </style>
 </head>
 <body>
  <table>
    <tr class="bb">
      <td>This</td>
      <td>should</td>
      <td>work</td>
    </tr>
  </table>
 </body>
</html>
David Andres
Thank you for your reply.But it's not working.
Shore
I stand corrected: try border-bottom: 1px solid black; instead.
David Andres
Still not working.
Shore
You can't style a `<tr>`, as it's only a "logical grouping element", but it's not actually rendered. You can only style the `<td>` or `<th>` elements inside the `<tr>`. Make sure you have some.
deceze
See my edit to this post. This is a bare bones html document, but I've added the !important clause to the style. This was done because, in your case, I can't tell what other styles have been defined and if any of these may have a higher specificity (i.e., priority) than what we're adding.
David Andres
+1  A: 

You should define the style on the td element like so:

<html>
<head>
    <style type="text/css">
        .bb
        {
            border-bottom: solid 1px black;
        }
    </style>
</head>
<body>
    <table>
        <tr>
            <td>
                Test 1
            </td>
        </tr>
        <tr>
            <td class="bb">
                Test 2
            </td>
        </tr>
    </table>
</body>
</html>
Eran Betzalel
why can't modify tr directly?
Shore
as **deceze** said: "You can't style a <tr>, as it's only a "logical grouping element", but it's not actually rendered. You can only style the <td> or <th> elements inside the <tr>. Make sure you have some."
Eran Betzalel
This is a good approach. The only thing I would caution against is that the size of the html render will grow in proportion to the number of TD elements in the table to class. If size is a concern, we will be more effective by targetting the table element itself a la table#idForTable tr td {border-bottom: 1px solid black}. One clause for the whole set of rows.
David Andres