Reputation: 1066
I know this is a dumb question but I seem to have totally forgotten how to do it.
I have a HTML table
and I want to remove all borders around all the cells so that there is only one border around the entire table.
My code looks like:
<table border='1' width='500'>
<tr><th><h1>Your Wheelbarrow</h1></th><tr>
<th>Product</th>
<th>Description</th>
<th>Price</th>
<th>Quantity</th>
<th>Total</th>
<th>Delete</th>
</tr>
Upvotes: 51
Views: 343451
Reputation: 518
As @brezanac mentioned, you can add the border-collapse, no need for anything else. I attach and example
.table {
border: 1px solid #CCC; // only for example
border-collapse: collapse;
}
th, td {
border: 1px solid #CCC; // only for example
}
<table aria-describedby="table without borders"
class="table">
<tr>
<th id="id">id</th>
<th id="name">name</th>
<th id="price">price</th>
</tr>
<tr>
<td>1</td>
<td>Pizza</td>
<td>7.99</td>
</tr>
<tr>
<td>2</td>
<td>Burger</td>
<td>3.99</td>
</tr>
</table>
<br/>
<table aria-describedby="table with borders">
<tr>
<th id="id">id</th>
<th id="name">name</th>
<th id="price">price</th>
</tr>
<tr>
<td>1</td>
<td>Pizza</td>
<td>7.99</td>
</tr>
<tr>
<td>2</td>
<td>Burger</td>
<td>3.99</td>
</tr>
</table>
Upvotes: 0
Reputation: 3783
If none of the solutions on this page work and you are having the below issue:
You can simply use this snippet of CSS:
td {
padding: 0;
}
Upvotes: 1
Reputation: 947
Just use your table inside a div with a class (.table1
for example) and don't set any border for this table in CSS. Then use CSS code for that class.
.table1 {border=1px solid black;}
Upvotes: 3
Reputation:
Just collapse the table borders and remove the borders from table cells (td
elements).
table {
border: 1px solid #CCC;
border-collapse: collapse;
}
td {
border: none;
}
Without explicitly setting border-collapse
cross-browser removal of table cell borders is not guaranteed.
Upvotes: 91
Reputation: 10677
Probably you just needed this CSS rule:
table {
border-spacing: 0px;
}
Upvotes: 5
Reputation: 201568
The HTML attribute for the purpose is rules=none
(to be inserted into the table
tag).
Upvotes: 17
Reputation: 4007
You might want to try this: http://jsfiddle.net/QPKVX/
Not really sure what you want your final layout to look like- but that fixes the colspan problem too.
Upvotes: 3
Reputation: 80639
Change your table declaration to:
<table style="border: 1px dashed; width: 500px;">
Here is the sample in action: http://jsfiddle.net/kc48k/
Upvotes: 2