Questy's Learning Area, tutorials and lessons

Building a better web site ...

Questy's, HTML Using Tables

Green & Purple line, Questy's Colors!

Tables are very useful for presentation of tabular information as well as a way for creative HTML authors to organize their regular Web pages.

The <TABLE> tag is used to declare the start and end of a table. All table elements are placed between the <TABLE> opening and closing tags. (If the BORDER attribute is present, your browser displays the table with a border.)

The <TD> tags adds what are equivalent to vertical columns to a table. Each time a table row is created using the <TR> tag, that row can be divided into vertical columns or cells by using the <TD> tag.

The code to create the one row/two cell table would look similar to the code below:
<TABLE>
<TR>
<TD></TD>
<TD></TD>
</TR>
</TABLE>

Commonly used attributes of the <TR> tag are:
ALIGN
VALIGN
BGCOLOR

Commonly used attributes of the <TD> tag are:
ROWSPAN
COLSPAN
WIDTH
HEIGHT
ALIGN
VALIGN
BGCOLOR

Use the VALIGN attribute to specify vertical alignment of an item within a cell such as text that is vertically centered. This attribute supports top, middle, bottom, and baseline as values.

The ALIGN differs from the VALIGN attribute in that it aligns horizontally within a cell. ALIGN supports the values left, center, right and justify.

To add a background color, use the BGCOLOR attribute using the hexadecimal code for the color.

The COLSPAN attribute is used with the <TD> tag to define how many columns wide a cell should be. For example, this code, <TD COLSPAN="3">, means that this table cell will span three columns.

To define table cells that will span over a specified amount of rows use the ROWSPAN attribute. This code, <TD ROWSPAN="3">, specifies that this table cell spans three rows.

Other table tags that are used, but not manditory include:

<CAPTION> ... </CAPTION> defines the caption for the title of the table. The default position of the title is centered at the top of the table. The attribute ALIGN=BOTTOM can be used to position the caption below the table. Any kind of markup tag can be used in the caption.

<TH> ... </TH> defines a table header cell. By default the text in this cell is bold and centered. Table header cells may contain other attributes to determine the characteristics of the cell and/or its contents.
Nested tables are created by putting a table within an existing table cell thereby placing one table within another table. The HTML code used in the answer begins by creating a main table that contains two cells. The first cell contains the word "text", and the second cell contains a nested table that also has two cells.

Nesting tables provides Web designers a way to further subdivide their table space. If more than three tables are nested into one main table, it could be that the overall design of the table needs to be reconsidered. Too many nested tables can cause pages to load slowly.

Borderless Page Structure

By default, an 8 pixel gap exists between the content of a Web page and the border of a browser window. This gap can be completely eliminated in Internet Explorer, but only reduced in Netscape Navigator.

To eliminate the gap that appears between page content and the edge of a browser window in Internet Explorer, set the TOPMARGIN and LEFTMARGIN attributes in the <BODY> tag to zero.

A similar code can be used to reduce the gap in Netscape Navigator. However, the attributes would be different than those used for Internet Explorer browsers. For Netscape Navigator, set the MARGINHEIGHT and MARGINWIDTH attributes to zero. The code would be as follows:

<BODY MARGINHEIGHT="0" MARGINWIDTH="0">

Using table borders with images and colors can create an impressive display as well. Use the example tables on the next page to experiment and see what you like.

turn the page...Next Page

Welcome to Questy's World

Welcome to the World of Questy

Welcome to the World of Questy -- The World of Questy Sites are currrently undergoing a major overhaul. Stay tuned for updated links and news in 2008!

Unless otherwise credited all photos and graphics are the copyrighted property of Questy aka Tom Peracchio. Unauthorized reproduction of any of the pages of this web site is illegal, not to mention rude.
- Copyright 1990 through 2008 -