Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set border to <tbody> element?

Why doesn't the border show around tbody in the following? I tried rules="groups" and the border appears, but only between the two tbody sections and it is collapsed.

table.sectioned tbody {    border: 2px solid black;    border-collapse: separate;    border-spacing: 4px;  }
<table class="sectioned">    <tbody>      <tr><td colspan="2"><b>General Data</b></td></tr>      <tr><td>Tail Number</td><td>N0809021</td></tr>      <tr><td>Type of Ownership</td><td>personal</td></tr>      <tr><td>Type of Aircraft</td><td>aircraft under 13,000 pounds</td></tr>      <tr><td>Year of Manufacture</td><td>1999</td></tr>      <tr><td>Use of Aircraft</td><td>private</td></tr>      <tr><td>Start Date</td><td></td></tr>      <tr><td>Policy Length</td><td>6 months</td></tr>    </tbody>    <tbody>      <tr><td colspan="2"><b>Additional Aircraft Information</b></td></tr>      <tr><td>Manufacturer</td><td></td></tr>      <tr><td>Model</td><td></td></tr>      <tr><td>Engine Make</td><td></td></tr>      <tr><td>Number of Seats</td><td></td></tr>    </tbody>  </table>
like image 709
George Avatar asked Sep 24 '13 19:09

George


People also ask

How do you give an element a border?

Borders can be applied to most HTML elements within the body. To make a border around an element, all you need is border-style . The values can be solid , dotted , dashed , double , groove , ridge , inset and outset . Basic border styles.

How do I add a border in TD?

To create table border in HTML, the border attribute was used. But the introduction of HTML5, deprecated the border tag. Create table border using the CSS property border. Set table border as well as border for <th> and <td>.

How do you put a border around a cell in HTML?

The HTML <table> border Attribute is used to specify the border of a table. It sets the border around the table cells. Attribute Values: 1: It sets the border around the table cells.


2 Answers

Add:

table {border-collapse: collapse;} 

FIDDLE

like image 159
Riskbreaker Avatar answered Sep 22 '22 09:09

Riskbreaker


Add display:block to your tbody style. Try this

tbody{     display:block;     border: 2px solid black;     border-collapse: separate;     border-spacing: 4px;  } 

You can test it out on this fiddle

like image 33
Brian Kinyua Avatar answered Sep 20 '22 09:09

Brian Kinyua