Alexander Spiteri's Home Page

HTML
Tables
 
Table Sintax
 
There's a great number of HTML tags to work with tables. We will only consider the most important ones along with their main attributes.

Just to start, let us consider a very simple and basic example. To create the following table:

  Column 1 Column 2
Row 1 Cell 1,1 Cell 1,2
Row 2 Cell 2,1 Cell 2,2

you would need the following HTML code:

<TABLE BORDER=1 CELLPADDING=2 CELLSPACING=1>
  <TR>
    <TH>&nbsp;</TH>
    <TH>Column 1</TH>
    <TH>Column 2</TH>
  </TR>
  <TR>
    <TH>Row 1</TH>
    <TD>Cell 1,1</TD>
    <TD>Cell 1,2</TD>
  </TR>
  <TR>
    <TH>Row 2</TH>
    <TD>Cell 2,1</TD>
    <TD>Cell 2,2</TD>
  </TR>
</TABLE>

Don't get anxious to understand all this code. This is only to give you an idea of what it takes to create table.

Here's a brief explanation of the main tags you will have to use to create tables like this one:

 
<TABLE ...> ... </TABLE>
  This is the main container of all the other table tags.
In fact, all those other tags will be ignored by the browser if they aren't wrapped inside of a TABLE tag.
 
<TR ...> ... </TR>
  The TR tag stands for table row.
The number of rows in a table is exactly specified by how many TR tags are contained within it.
 
<TD ...> ... </TR>
  This stands for table data and specifies a standard data cell.
TD tags must only appear within table rows and they can contain any of the HTML tags normally present in the body of an HTML document.
 
<TH ...> ... </TH>
  TH stands for table header.
Header cells are identical to data cells in all respects, with the exception that header cells are in a bold font, and have a default ALIGN=center.
 
<CAPTION ...> ... </CAPTION>
  This represents the table caption
CAPTION tags should appear inside the TABLE but not inside table rows or cells.
 
These tags will probably be the only ones you'll need to create highly sophisticated tables and an high-impact design for your Web pages.

Off course you'll need to use some fancy attributes - like CELLPADDING or VALIGN - and we'll introduce you to the most important ones in the next subjects. If you would like to get to it right now, check the Tag Reference section for a complete description of these and other table elements.

 
Related Topics
 
TABLE element - TR element - TD element - TH element - CAPTION element
 
Index
 
 

Introduction
Table Sintax
Tricks
Examples

 
Back to Alexander Spiteri's Home