Creating a Web Page VI : Tables

0 Conversations

Please refer to previous entries in the "Creating a Web Page" series:

Good luck...

Be warned now that tables are one of a webmaster's biggest bugaboos. You can drive yourself crazy trying to get it to look exactly as you want since there are so many possible attributes (customizable features), and results will vary from one browser to the next. Thus warned, let us plunge into the fray...

Here are the simplest tags to form a table. TR stands for "table row", and TD for "table data", or one cell.

Sample HTML:

<TABLE>
<TR>
<TD> row1column1</TD>
<TD> row1column2</TD>
<TD> row1column3</TD>
</TR>
<TR>
<TD> row2column1</TD>
<TD> row2column2</TD>
<TD> row2column3</TD>
</TR>
<TR>
<TD> row3column1</TD>
<TD> row3column2</TD>
<TD> row3column3</TD>
</TR>
</TABLE>

Result:

row1column1row2column1row3column1
row1column2row2column2row3column2
row1column3row2column3row3column3

All of the following attributes fall within the TABLE tag:

  • BORDER
  • ...draws a border x pixels wide around the table

  • BORDERCOLOR
  • ...sets the border's color.

  • CELLSPACING
  • sets the number of pixels (amount of space) around and between cells

  • CELLPADDING
  • gives you x number of pixels of space in the cell inside the cell around your text or data

  • HSPACE and VSPACE
  • set the amount of space around the table in pixels

  • ALIGN
  • can align the table either LEFT, RIGHT, or CENTER on the page.

<TABLE BORDER=3 BORDERCOLOR="#CC0033" CELLSPACING=3 CELLPADDING=3 HSPACE=5 VSPACE=5 ALIGN=CENTER>
<TR ALIGN=LEFT>
<TD> row1column1</TD>
<TD> row1column2</TD>
<TD> row1column3</TD>
</TR>
<TR ALIGN=CENTER>
<TD> row2column1</TD>
<TD> row2column2</TD>
<TD> row2column3</TD>
</TR>
<TR ALIGN=RIGHT>
<TD> row3column1</TD>
<TD> row3column2</TD>
<TD> row3column3</TD>
</TR>
</TABLE>

While not all of the attributes can be demonstrated within the Guide, here are what borders and alignments can do.

row1
column1 
row2
column1 
row3
column1 
row1
column2 
row2
column2 
row3
column2 
row1
column3 
row2
column3 
row3
column3 

As for the other attributes, the only other that will be presented here is found in the TD tag. NOWRAP is handy since if your table contains a long line of text, it will stay all on one line. (Otherwise, the browser would automatically make it fit the other cells, and there are times when you may not want it to.)

Sample HTML:

<TD nowrap> Here is a long cell in the table.</TD>

Unfortunately, the Guide does not support this feature at this time. You'll just have to experiment with this one. The only disadvantage of NOWRAP is that it will stretch all the other cells in that column to fit the longest cell, but sometimes that's preferable to having it wrap the words, and sometimes you'll prefer the look of the table if the cells are wrapped.

There are many other attributes available that start to go beyond beginning web design. If you'd like to learn more of them, you can consult Netscape's online HTML tag reference, or a printed HTML guide.


Bookmark on your Personal Space


Conversations About This Entry

There are no Conversations for this Entry

Entry

A669224

Infinite Improbability Drive

Infinite Improbability Drive

Read a random Edited Entry


Written and Edited by

References

External Links

Not Panicking Ltd is not responsible for the content of external internet sites

Disclaimer

h2g2 is created by h2g2's users, who are members of the public. The views expressed are theirs and unless specifically stated are not those of the Not Panicking Ltd. Unlike Edited Entries, Entries have not been checked by an Editor. If you consider any Entry to be in breach of the site's House Rules, please register a complaint. For any other comments, please visit the Feedback page.

Write an Entry

"The Hitchhiker's Guide to the Galaxy is a wholly remarkable book. It has been compiled and recompiled many times and under many different editorships. It contains contributions from countless numbers of travellers and researchers."

Write an entry
Read more