Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Controlling space between table rows 3

Status
Not open for further replies.

piratefan

Programmer
Jul 20, 2003
195
US
Code:
<table>
  <tr>
    <td>One</td>
  </tr>
  <tr>
    <td>Two</td>
  </tr>
</table>

I have code that is basically the above. For some reason there are huge spaces between the rows. Any help appreciated.
Thanks.
 
piratefan,

What browser does it break in for you?

Do you have any style sheets either attached to, or embedded on the page that could be altering the height of table, tr, or td elements?

Try putting &quot;height=1&quot; in your table tag and seeing if that makes any difference.

Dan
 
The code you have pasted could not generate *huge* spaces between rows. It also depends what you mean by huge. If you do not specify the cellspacing, cellpadding and border attributes in your table tag default values will be used (border spacing 2px and cell padding 1px) and that will cause an extra space (not a huge one in my opinion though). Try giving us a link (or the code) to the exact table that is causing the problems.
 
To elaborate on Vragabond, your code should look something like this:

<table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;>
<tr><td>One</td></tr>
<tr><td>Two</td></tr>
</table>

Note that there are no tabs and no carriage returns within a table cell or row (<tr><td></td></tr>). This type of table coding works in all browsers and will not produce any spaces between table rows unless you place images in the cells that are of different heights or you use a style sheet that produces different size fonts in table cells within a table row.

There's always a better way. The fun is trying to find it!
 
I'm embarrassed to say it was a height attribute doing it. But I am catching on.
One thing I have noticed as tviman stated. Putting the <tr> and <td> on one line reduces whitespace(I guess you call it that). I have a tool I work with called Web Matrix. When I do that, it automatically reformats to :
<td>
text
</td>
I have to use notepad to get them to stay on the same line.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top