Welcome to WebmasterWorld Guest from 54.211.86.24

Forum Moderators: not2easy

Controlling Table Cell Spacing in CSS

Controlling Table Cell Spacing in CSS

   
12:28 pm on Apr 6, 2005 (gmt 0)

10+ Year Member



Hi,

I am currently doing one project. In that I need to give cell spacing of table in CSS. If I give common property It comes in all the table. But I have to differentiate the table using class ID .I would like to know how to control the cell spacing of table in CSS.Please help me.

Vivek

12:29 pm on Apr 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



#mytable td {
margin:12px;
}
12:44 pm on Apr 6, 2005 (gmt 0)

10+ Year Member



Hai thanks for ur reply,

Actual Thing I need is I want to control cell spacing in the CSS class itself, I should not give in in the table property <table cellspacing="1"> I want to give in the CSS class itself. Thats my requirement.

12:51 pm on Apr 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



sorry was in a hurry earlier.

in my post, which is reffereing to a css file,:

#mytable td {
margin:12px;
}

#mytable will match the html <table id="mytable">

td will match any <td> inside <table id="mytable">, and give it a margin of 12px, which if i understand correctly, is what you are asking. You can just as easily use a class by referencing as .mytable instead of #mytable. Using 12px will give large gaps, so you wil have to edit that.

1:02 pm on Apr 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The CSS equivalent of cellspacing is border-spacing.

td {
border-spacing:10px;
}

Not supported by IE, or is it?

1:27 pm on Apr 6, 2005 (gmt 0)

10+ Year Member



Thanks for ur reply,

But still the requirment is not fulfilled. My requirement is

1. A table , in that only one row and one column.table no 1.

2. OK. Inside that table, I am placing another table with 3 rows and 3 columns, this is table no2.For this table I am giving Cell spacing as 1.eg <table cellspacing=1>.

3. If I give table no 1 bgcolor= red means , the Inner table will be tablised. using the cellspacing the outline of table 2 will be red.

4. this thing I want to make it in CSS , all other attributes I gave in CSS its working only this cellspacing is pending,

I tried the above 2 steps given above, but It didnt come, I want to give that attribute in a class and call it for some particular table only I want to use.

this is my requirement

vivek

1:41 pm on Apr 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



ok. i see what youre getting at, and my answer doesnt cut it. youll have to wait for someone else to chip in.
9:24 pm on Apr 6, 2005 (gmt 0)

10+ Year Member



[ edit ] fixed. [ /edit ]

I'm not sure you need to nest the table for it to work:

#table1 {
border-collapse: collapse;
}

#table1 td {
border: 2px solid red; /* 'cellspacing' */
}

<table id="table1">
<tr>
<td>AAA</td>
<td>AAA</td>
<td>AAA</td>
</tr>
<tr>
<td>AAA</td>
<td>AAA</td>
<td>AAA</td>
</tr>
<tr>
<td>AAA</td>
<td>AAA</td>
<td>AAA</td>
</tr>
</table>
1:20 am on Apr 7, 2005 (gmt 0)

10+ Year Member



ok, span, now why in the world didn't you answer that question when i asked it about a week ago? you even posted in the thread but left no answer..
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month