102

I have a peculiar and frustrating problem. For the simple markup:

<table>
    <thead>
        <tr><th>1</th><th>2</th><th>3</th></tr>
     </thead>
    <tbody>
        <tr><td>a</td><td>b></td><td>c</td></tr>
        <tr class='odd'><td>x</td><td>y</td><td>z</td></tr>
    </tbody>
</table>

I apply different background-color values to the thead, tr, and tr odd elements. The problem is that in most browsers, every cell has an unwanted border which is not the color of any of the table rows. Only in Firefox 3.5 does the table have no borders in any cell.

I'd just like to know how to remove these borders in the other major browsers so that the only thing you see in the table are the alternating row colors.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Bob
  • 1,080
  • 2
  • 7
  • 6
  • 2
    Thanks to everyone who suggested adding border-collapse:collapse to the CSS. That did it. – Bob Jan 11 '10 at 01:47

8 Answers8

234

You need to add this to your CSS:

table { border-collapse:collapse }
Josh Crozier
  • 233,099
  • 56
  • 391
  • 304
Doug Neiner
  • 65,509
  • 13
  • 109
  • 118
  • 14
    Note that this has to be applied to the _table_, not the _td_'s. I just made this mistake and spent upwards of half an hour trying to figure out why it wasn't working. – javawizard Jul 05 '14 at 02:22
31

to remove the border , juste using css like this :

td {
 border-style : hidden!important;
}
Aouidane Med Amine
  • 1,571
  • 16
  • 17
22

Modify your HTML like this:

<table border="0" cellpadding="0" cellspacing="0">
    <thead>
        <tr><td>1</td><td>2</td><td>3</td></tr>
     </thead>
    <tbody>
        <tr><td>a</td><td>b></td><td>c</td></tr>
        <tr class='odd'><td>x</td><td>y</td><td>z</td></tr>
    </tbody>
</table>

(I added border="0" cellpadding="0" cellspacing="0")

In CSS, you could do the following:

table {
    border-collapse: collapse;
}
Jefferson
  • 794
  • 10
  • 24
Gabriel McAdams
  • 56,921
  • 12
  • 61
  • 77
9

Set the cellspacing attribute of the table to 0.

You can also use the CSS style, border-spacing: 0, but only if you don't need to support older versions of IE.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
1

After trying the above suggestions, the only thing that worked for me was changing the border attribute to "0" in the following sections of a child theme's style.css (do a "Find" operation to locate each one -- the following are just snippets):

.comment-content table {
    border-bottom: 1px solid #ddd;

.comment-content td {
    border-top: 1px solid #ddd;
    padding: 6px 10px 6px 0;
}

Thus looking like this afterwards:

.comment-content table {
    border-bottom: 0;

.comment-content td {
    border-top: 0;
    padding: 6px 10px 6px 0;
}
Jason Sturges
  • 15,855
  • 14
  • 59
  • 80
1

You may also want to add

table td { border:0; }

the above is equivalent to setting cellpadding="0"

it gets rid of the padding automatically added to cells by browsers which may depend on doctype and/or any CSS used to reset default browser styles

falc0n
  • 21
  • 1
  • 1
    Cellpadding is the space between the table content and its boundries `td{padding:X}`. Cellspacing is the space between each cell's bourdries ("margin" between cell borders). You can set `border-collapse` to mimic what the `cellspacing` attribute does on the table tag, but it's not foolproof. – MetalFrog Mar 13 '12 at 19:17
0

Try assigning the style of border: 0px; border-collapse: collapse; to the table element.

Josh Anderson
  • 5,975
  • 2
  • 35
  • 48
-1

sometimes even after clearing borders.

the reason is that you have images inside the td, giving the images display:block solves it.

dippas
  • 58,591
  • 15
  • 114
  • 126
bresleveloper
  • 5,940
  • 3
  • 33
  • 47