2

I'm trying to apply background-color to a table-cells. jsFiddle

<table>
<tr>
            <td>
                text
            </td>
            <td>
                text
            </td>
            <td>
                text
            </td>
</tr>
</table>


td{
    background-color: rgb(172,0,20);
}

How can I remove spacing between the table cells?

4 Answers4

1

Just add the border-collapse property for the table:

CSS

table{
    border-collapse:collapse;
}
td{
   background-color: rgb(172,0,20);
}

http://jsfiddle.net/DKNyf/1/

leigero
  • 3,233
  • 12
  • 42
  • 63
0

try using like this

<table cellspacing="0" cellpadding="3" border="0">
<tr>
    <td>text</td>
    <td>text</td>
    <td>text</td>
</tr>
</table>
PravinS
  • 2,640
  • 3
  • 21
  • 25
0

The space between cells is called cellspacing and can be assigned in the html by using:

<table cellspacing="0">
<tr>
            <td>
                text
            </td>
            <td>
                text
            </td>
            <td>
                text
            </td>
</tr>
</table>

see: http://www.w3schools.com/tags/att_table_cellspacing.asp

You can also do this through CSS, see: Set cellpadding and cellspacing in CSS?

Community
  • 1
  • 1
Luceos
  • 6,629
  • 1
  • 35
  • 65
0

Use CSS:

table {
    border-collapse:collapse;
}

jsFiddle example

Ref: https://developer.mozilla.org/en-US/docs/Web/CSS/border-collapse

j08691
  • 204,283
  • 31
  • 260
  • 272