Forum Moderators: open

Message Too Old, No Replies

Row spacing in tables

I need to do this...

         

adni18

12:34 pm on Oct 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a table (with two rows), and I need to make the row on bottom 0px away from the one on top. This may be a job for the CSS dept, so I will post this there as well.

walrus

1:45 pm on Oct 13, 2004 (gmt 0)

10+ Year Member



What about using the cell values in the table
CELLPADDING="4" CELLSPACING="2"

encyclo

2:18 pm on Oct 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you want no space at all between table rows and cells, then all you need is:

<table cellspacing="0" cellpadding="0">

There is no exact CSS equivalent, and so the above is valid in all standards, transitional and strict.

gohankid77

3:43 pm on Oct 13, 2004 (gmt 0)

10+ Year Member



td {
margin: 0; /* Isn't this the same as cellspacing="0"? */
padding: 0; /* Isn't this the same as cellpadding="0"? */
}

I always thought that was how to do it. Borders are a bit different in HTML and CSS, so I suppose those could be different.

adni18

7:31 pm on Oct 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I did that, but there is still a slight space between the first and second row.

tedster

7:47 pm on Oct 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What about the elements in the table cells? Maybe you are seeing margin or padding associated with a <p> or <img> element. what do you see when you turn on border=1 for the table? Or use css to give the table cell elements a border?

Also, some browsers render a line break in your HTML doc gets rendered as extra space.

gohankid77

7:47 pm on Oct 13, 2004 (gmt 0)

10+ Year Member



That's what I figured.

tr {
margin: 0;
padding: 0;
}

That might work.

/* Edit */

Nevermind what I just posted now. You will always have spacing between rows whether you use HTML or CSS.

encyclo

8:03 pm on Oct 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You will always have spacing between rows whether you use HTML or CSS.

As I said in message 3 - you need the cellpadding and cellspacing set to zero in the HTML, and then you get no spaces between the

<tr>
elements.

There is currently no way to do this with CSS, and that is why the example I gave will validate even if you're using XHTML 1.0 Strict or 1.1.

gohankid77

8:10 pm on Oct 13, 2004 (gmt 0)

10+ Year Member



Actually, my example eliminates the same amount of space as yours.

/* Edit */

---------
Directions for being wrong:

1. Open mouth
2. Insert foot

---------

It looks like you are right. It eliminates almost the same amount of space, though.

walrus

5:49 am on Oct 14, 2004 (gmt 0)

10+ Year Member



OOPs!
I forgot to set the values to zero
in my post.
Doh!