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

Hi I just cant get the hang of t 1

Status
Not open for further replies.

Brian56

Programmer
May 29, 2003
66
CA
Hi

I just cant get the hang of this. What I need to do is insert a table inside a table.
 
The inner table needs to sit inside a cell of the outer table, eg:

<TABLE>
<TR>
<TD>
THIS IS A CELL IN YOUR OUTER TABLE WHICH CONTAINS: <TABLE><TR><TD>THIS TEXT IS INSIDE THE NESTED TABLE</TD></TR></TABLE>
..SO THE COMPLETE INNER TABLE SITS INSIDE ONE CELL OF THE OUTER TABLE. NOW CLOSE THE OUTER TABLE CELL, ETC.
</TD>
</TR>
</TABLE>
 
One thing I always do to make sure anything I code is opened and closed properly is to write the open and close tags right away at the same time before filling things in between. So to nest a table within a table firstI would do:

<table>
<tr>
<td>

</td>
</tr>
</table>


THEN I'd do my second table inside the same way:

<table>
<tr>
<td>

<table>
<tr>
<td>

</td>
</tr>
</table>


</td>
</tr>
</table>

This way I know all my tags are properly closed before I put in anything else. Using comments in the code also helps. These don't show up in the browser, but are helpful for you when looking at the code:

<!--Open Main table -->
<table>
<tr>
<td>

<!--Open Sub table -->
<table>
<tr>
<td>

<!--Close Sub table -->
</td>
</tr>
</table>

<!--Close Main table -->
</td>
</tr>
</table>


Hope this is helpful!
 
Indenting can be very, very helpful, too. Makes it more readable!:

Code:
<!--Open Main table -->
<table>
  <tr>
    <td>
      <table> <!--Open Sub table -->
        <tr>
          <td>
            inner, inner content
          </td>
        </tr>
      </table> <!--Close Sub table -->
    </td>
  </tr>
</table> <!--Close Main table -->

For some, it's just being a control freak. For me, it's invaluable to keeping track of pieces.

BHaines advice is dead-on -- build your outer container first until you're happy with it. Then build what goes inside it.

Of course, my advice is that you probably don't need nested tables anyway -- design your page such that you don't need 'em and you'll be a lot happier.

Cheers,


[monkey] Edward [monkey]

&quot;Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!&quot; -- inventor of the cat door
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top