user8323337
user8323337

Reputation:

How to remove only bottom border on specified row in html table

I have simple html table on which I want to remove bottom border of tr on specific row.

The table

<table cellpadding="5">
    <thead>
        <tr valign="top">
            <th>Title</th>
            <th>Title 2</th>
            <th>Title 3</th>
            <th>Title 4</th>
        </tr>
    </thead>

    <tbody>
        <tr>
            <td>Test Entry</td>
            <td>Test Entry</td>
            <td>Test Entry</td>
            <td>Test Entry</td>
        </tr>

        <tr class="no-bottom-border">
            <td>Test Entry</td>
            <td>Test Entry</td>
            <td>Test Entry</td>
            <td>Test Entry</td>
        </tr>
        <tr>
            <td>Test Entry</td>
            <td>Test Entry</td>
            <td>Test Entry</td>
            <td>Test Entry</td>
        </tr>
    </tbody>
</table>

What I've tried is to add class to the tr which I want to be without bottom border class="no-bottom-border" and with css to remove it

tr .no-bottom-border {border-bottom: none}

This doesn't seems to work. Here is the JSFIDDLE with the table

Upvotes: 9

Views: 28746

Answers (2)

Buwaneka Sudheera
Buwaneka Sudheera

Reputation: 1417

I copied your code and tried to change it.You just have to remove the border of all td inside .no-bottom-border tr, instead of removing the border of tr.

.no-bottom-border td {
  border-bottom: none;
}

Upvotes: 5

zer00ne
zer00ne

Reputation: 43870

Target the borders of td, because tr has no border properties.

Demo

table,
caption,
tbody,
tfoot,
thead,
tr,
th,
td {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  vertical-align: baseline;
  background: transparent;
}

table {
  border: 1px solid #ccc;
  color: #37393b;
  margin: 10px 0 0 0;
  text-shadow: #fff 1px -1px 1px;
  text-align: left;
  width: 100%;
}

table tbody tr td {
  background: #FFF;
  border-bottom: 1px dotted #d00;
}

tr.no-bottom-border td {
  border-bottom: none
}
<table cellpadding="5">
  <thead>
    <tr valign="top">
      <th>Title</th>
      <th>Title 2</th>
      <th>Title 3</th>
      <th>Title 4</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>Test Entry</td>
      <td>Test Entry</td>
      <td>Test Entry</td>
      <td>Test Entry</td>
    </tr>

    <tr>
      <td>Test Entry</td>
      <td>Test Entry</td>
      <td>Test Entry</td>
      <td>Test Entry</td>
    </tr>

    <tr class="no-bottom-border">
      <td>Test Entry</td>
      <td>Test Entry</td>
      <td>Test Entry</td>
      <td>Test Entry</td>
    </tr>
    <tr>
      <td>Test Entry</td>
      <td>Test Entry</td>
      <td>Test Entry</td>
      <td>Test Entry</td>
    </tr>
  </tbody>
</table>

Upvotes: 6

Related Questions