user2953119
user2953119

Reputation:

Table cell's spacing

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?

Upvotes: 2

Views: 40

Answers (4)

j08691
j08691

Reputation: 208002

Use CSS:

table {
    border-collapse:collapse;
}

jsFiddle example

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

Upvotes: 0

leigero
leigero

Reputation: 3283

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/

Upvotes: 1

Luceos
Luceos

Reputation: 6730

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?

Upvotes: 0

PravinS
PravinS

Reputation: 2584

try using like this

<table cellspacing="0" cellpadding="3" border="0">
<tr>
    <td>text</td>
    <td>text</td>
    <td>text</td>
</tr>
</table>

Upvotes: 0

Related Questions