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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Table inside a table and its valign.

Status
Not open for further replies.

blfrd76

Programmer
Jul 17, 2003
34
US
I have a table inside a table. However, I do not want a big space and a line break inside the first cell of the first table (which contains the second). Is this due to the fact that tables are block level instead of in-line? Here's my code:

<html>
<head> TEST1
<title>TABLES</title>
</head>
<body>
<TABLE BORDER=&quot;3&quot; CELLPADDING=&quot;1&quot; CELLSPACING=&quot;1&quot;>
<TD CELLPADDING=&quot;0&quot; CELLSPACING=&quot;0&quot; valign=&quot;top&quot; align=&quot;center&quot;>Unwanted Space and line break
<TABLE valign=&quot;top&quot; BORDER=&quot;1&quot; CELLPADDING=&quot;0&quot; CELLSPACING=&quot;0&quot;>
<TD CELLPADDING=&quot;0&quot; CELLSPACING=&quot;0&quot;>Table inside a table</TD>
<TR CELLPADDING=&quot;0&quot; CELLSPACING=&quot;0&quot;>
<TD>2nd row of table inside table</TD>
<br/>
</tr>
</TABLE>TEST2
</TD>
<TD> TEST
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
</TD>
</TABLE>
</body>
</html>


Any help is appreciated

Bill

 
That happens because of the messy code, full of errors. Here are the top ones.

<head> TEST1
<title>TABLES</title>

This text should not be here. The browser really has no idea what to do with this text.

<TABLE BORDER=&quot;3&quot; CELLPADDING=&quot;1&quot; CELLSPACING=&quot;1&quot;>
<tr>
<TD CELLPADDING=&quot;0&quot; CELLSPACING=&quot;0&quot; valign=&quot;top&quot; align=&quot;center&quot;>

Please check proper way to create tables. The tags must be followed in this order: <table><tr><td></td></tr></table>. This means: table, table row, table cell.
You are using attributes that don't exist. Check websites, such as or for the list of available attributes inside certain tags.

To help you started, here is the proper code for what you just did. Another thing. Identing your code is useful, since you can easily see how deep in the nested elements you are.

Code:
<html>
 <head>
  <title>TABLES</title>
 </head>
 <body>
  <TABLE BORDER=&quot;3&quot; CELLPADDING=&quot;1&quot; CELLSPACING=&quot;1&quot;>
   <tr>
    <TD valign=&quot;top&quot; align=&quot;center&quot;>
     <TABLE valign=&quot;top&quot; BORDER=&quot;1&quot; CELLPADDING=&quot;0&quot; CELLSPACING=&quot;0&quot;>
      <tr>
       <TD>Table inside a table</TD>
      </tr>
      <TR>
       <TD>2nd row of table inside table</TD>
      </tr>
     </TABLE>
     TEST2
    </TD>
    <TD>
     TEST
     <br/>
     <br/>
     <br/>
     <br/>
     <br/>
     <br/>
     <br/>
     <br/>
     <br/>
     <br/>
     <br/>
     <br/>
    </TD>
   </tr>
  </TABLE>
 </body>
</html>
[code]

Hope it helps.
 
Is this what you are trying to achive?
Code:
<TABLE BORDER=&quot;3&quot; CELLPADDING=&quot;1&quot; CELLSPACING=&quot;1&quot;>
	<tr>
		<TD valign=&quot;top&quot; align=&quot;center&quot;>
			<TABLE valign=&quot;top&quot; BORDER=&quot;1&quot; CELLPADDING=&quot;0&quot; CELLSPACING=&quot;0&quot;>
				<tr>
					<TD>Table inside a table</TD>
				</tr>
				<tr>
					<TD>2nd row of table inside table</TD>			
				</tr>
			</TABLE>
		</TD>	
		<TD>TEST</TD>
	</tr>
</TABLE>
 
Why not use CSS for layout? Tables take too long to load a page.
 
>That happens because of the messy code, full of errors. >Here are the top ones.

I did not write the basis for this code. The site I obtained it from indicates that tags must be ended, but the code example does not do that. Here is where I got it:


>You are using attributes that don't exist. Check websites, >such as or for >the list of available attributes inside certain tags.


I'm familiar with and the like.

>Identing your code is useful, since you can easily see how >deep in the nested elements you are.

You're right. I wasn't sure if the code would format correctly if I indented. But I guees it will.

Actualy I found a more efficient way to solve my problem using css. But thanks anyway....

Bill
 
Actualy, &quot;CELLPADDING&quot; & &quot;CELLSPACING&quot; attributes do exist but they belong to a <table> element, not <td>. site clearly explains that. Also, in your initial script, both tables are missing the <tr> tag before the first cell. So Vragabond is right - this code is messy, no matter who wrote it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top