Personal Space Workshop - Tables

0 Conversations

Tables are quite complex, so you may not wish to attempt using one until you are happy with at least the basic Guide ML tags. However, a simple table is relatively easy to creat. There are 3 tags involved...

  • <TABLE> To put at the start of the table, with the closing tag </TABLE> at the end of the table.
  • <TR>At the beginning of each row, and </TR> at the end of each row.
  • <TD> To start each individul cell, closing with </TD>

Here's an example of a simple table..


SmileyNameShortcut
smiley - smileySmiley:-)
smiley - biggrinBiggrin:-D

And here's the code for how it was written..


<TABLE>
<TR>
<TD>Smiley</TD>
<TD>Name</TD>
<TD>Shortcut</TD>
</TR>
<TR>
<TD><SMILEY TYPE="smiley"/></TD>
<TD>Smiley</TD>
<TD>:-)</TD>
</TR>
<TR>
<TD><SMILEY TYPE="biggrin"/></TD>
<TD>Biggrin</TD>
<TD>:-D</TD>
</TR>
</TABLE>

The code looks quite long, but don't be put off by this. Remember there are only 3 different tags, they just get used repeatedly. smiley - ok

Adding to tags

Once you're happy with the basics, you may wish to try adding to tags to make a more complex table. This way you can add several extras, such as colour and cellpadding. This section is devided out into the three tags, the extras that can be added to them explained under each heading.

Table

Here adding to the <TABLE> tag is explored. Here you can add the following...

  • Width
  • Cellpadding
  • Border colour
  • Background colour

By using the width tag, you can chose how big you want your table to be. If you do not use this tag, the table will be the smallest possible size to fit the information it contains. To demonstrate, here is the same simple table, but with the opening tag changed to <TABLE WIDTH="50%">. Please note that the closing tag of </TABLE> does not change...


SmileyNameShortcut
smiley - smileySmiley:-)
smiley - biggrinBiggrin:-D

You can see the table is now half the width of the page smiley - magic. We could now chose to add more to the tag, to give a border. For the sake of the example, a border width of 3 is chosen... Now the opening tag is <TABLE WIDTH="50%" BORDER="3">, giving the following result..


SmileyNameShortcut
smiley - smileySmiley:-)
smiley - biggrinBiggrin:-D

Now the table looks more like a table smiley - biggrin, but there's more we can do. How about adding colour to the border? This can be done by adding BORDERCOLOR to the tag1. In this case, blue is chosen, now giving the opening tag of <TABLE WIDTH="50%" BORDER="3" BORDERCOLOR="blue">


SmileyNameShortcut
smiley - smileySmiley:-)
smiley - biggrinBiggrin:-D

Well isn't that colourful? smiley - rainbow But there're still some white spaces. To fill the table in the colour of your choice, the tag BGCOLOR needs to be used. In the example, the colour sky blue is chosen. Now the opening tag looks like this.. <TABLE WIDTH="50%" BORDER="3" BORDERCOLOR="blue" BGCOLOR="skyblue">


SmileyNameShortcut
smiley - smileySmiley:-)
smiley - biggrinBiggrin:-D

Now the table is really colourful smiley - bigeyes. However, you may decide you would like the cells to be a bit more padded. This can be achieved by the use of the CELLPADDING tag. In the example, a cell padding of 5 is chosen, giving an opening tag of <TABLE WIDTH="50%" BORDER="3" BORDERCOLOR="blue" BGCOLOR="skyblue" CELLPADDING="5">


SmileyNameShortcut
smiley - smileySmiley:-)
smiley - biggrinBiggrin:-D

See the difference? Now the table is looking much better than the original one, though all that was done were a few additions to the <TABLE> tag.

TR

The same sort of extras for the <TABLE> tag can be used on the opening <TR> tag, giving changes isolated to that table row. In the example, only the firt row will be altered, and the final result of the <TABLE> tag used (that's <TABLE WIDTH="50%" BORDER="3" BORDERCOLOR="blue" BGCOLOR="skyblue" CELLPADDING="5">).

First, the border color can be altered. In the example a border colour of indigo is chosen, changing the opening tag to <TR BORDERCOLOR="indigo">


SmileyNameShortcut
smiley - smileySmiley:-)
smiley - biggrinBiggrin:-D

As you can see, the result is exactly the same as on the <TABLE> tag, excep that the result is only on that table row. Thi is similar to when the back ground colour is changed. In the example, the back ground colour chosen is spring green, giving an opening tag of <TR BORDERCOLOR="indigo" BGCOLOR="springgreen">


SmileyNameShortcut
smiley - smileySmiley:-)
smiley - biggrinBiggrin:-D

Now the table is looking very colourful.

TD

Changes that can be made to the <TD> tag are the same as those to the <TR> tag. To demonstrate, changes will be made to the central cell (the one that's written <TD>Smiley</TD>), and the newest version of the table used (the one with all the additions to the <TABLE> and <TR> tags). First of all, lets change the BORDERCOLOR. For the example, red is chosen. Now the opening tag reads <TD BORDERCOLOR="red">, giving the result of..


SmileyNameShortcut
smiley - smileySmiley:-)
smiley - biggrinBiggrin:-D

Now to change the back ground colour. For the example, royal blue is chosen. Now the tag looks like <TD BORDERCOLOR="red" BGCOLOR="royalblue"/>


SmileyNameShortcut
smiley - smileySmiley:-)
smiley - biggrinBiggrin:-D

Now the table is very colourful, and looks quite complex, though all that was done were a few tags added too...

Further Changes

Still not satisfied with your table? There are plenty of other things that can be changed. Once you're happy with the basics, you may wish to try a few of them out. Here are a few examples...

  1. Align your table by altering the <TABLE> tag. For example, <TABLE ALIGN="CENTER"> to put the table in the middle of your space.
  2. Put tables inside each other for complex effects
  3. Use other tags, such as <FONT>, to change cells further.

Here some of the ideas have been put together, and the code is shown to show you how it was done.


Smiley
A smiley going through several mood changes
NameShortcut
smiley - smileySmiley:-)
smiley - biggrinBiggrin:-D
<TABLE WIDTH="50%" BORDER="3" BORDERCOLOR="blue" BGCOLOR="skyblue" CELLPADDING="5" ALIGN="center">
<TR BORDERCOLOR="indigo" BGCOLOR="springgreen">
<TD><FONT COLOR="yellow">Smiley </FONT><TABLE BORDER="2" BORDERCOLOR="purple"><TR><TD><PICTURE WIDTH="25" HEIGHT="25" BLOB="B1072983" ALT="A smiley going through several mood changes"/></TD></TR></TABLE></TD>
<TD><FONT COLOR="yellow">Name</FONT></TD>
<TD><FONT COLOR="yellow">Shortcut</FONT></TD>
</TR>
<TR>
<TD><SMILEY TYPE="smiley"/></TD>
<TD>Smiley</TD>
<TD>:-)</TD>
</TR>
<TR>
<TD><SMILEY TYPE="biggrin"/></TD>
<TD>Biggrin</TD>
<TD>:-D</TD>
</TR>
</TABLE>Back to the Personal Space Workshop
1Border colours may not operate on all browsers, for example Opera

Bookmark on your Personal Space


Conversations About This Entry

There are no Conversations for this Entry

Entry

A1131418

Infinite Improbability Drive

Infinite Improbability Drive

Read a random Edited Entry


Written and Edited by

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