J-Anna's Virtual Notebook


Explore Virtual University

This week I will learn to add tables to my page. Tables allow me to creatively organize, position, and arrange data on my web page. I will learn and practice basic tables.

The following is my first table:

Gardenias Lilacs
Roses Jasmine
Mums Carnations

Now I will add a border to my table.

Gardenias Lilacs
Roses Jasmine
Mums Carnations

Now I will center my table. There are two ways to do it. I will also utilize the summary attribute which will provide a verbal description of the table for those who use non-visual browsers (similar to the alt= attribute). You will also observe that I have named the table using the caption attribute.

Fragrant Flowers
Gardenias Lilacs
Roses Jasmine
Mums Carnations

Now I will demonstrate another table that will also include a Table Header.

J-Anna's Pets
Name Type Sex Longevity Special Comments
Jezebel Cat F 12 years Loved her dearly
Lady Dog F 11 years 140 lb. Sweetheart
Joshua Dog M 10 years Adored Josh
Taffy Dog F 6 years Penny's daughter
Penny Dog F 10 years Went everywhere with me
Cuddles Hamster M 2 years No more hamsters
Daisy Goldfish F 1 year A gift. A nuisance.
Donald Goldfish M 1 year Daisy's boyfriend
Snowball Parakeet M 5 years Not much of a talker
Cricket Dog F 5 years She learned tricks
Kookie Dog F 1 year My 1st dog. Lost her too soon
Chippy Parakeet M 5 years 40 word Vocabulary
Dusty Parakeet F 1 year My first pet


The attribute colspan creates a heading that covers more than one column by merging cells in either the or tag set. "Bright Birds" in the following table demonstrates this.


Bright Birds
Cardinals Scarlet Tanagers
Blue Jays Blue Birds
Hummingbirds Baltimore Orioles

Rowspan is an attribute that creates a heading or cell that stretches down the page versus across the page. It is also used in the same tag sets as colspan. See the following example.

Bright Birds
Cardinals Scarlet Tanagers
Blue Jays Blue Birds
Hummingbirds Baltimore Orioles

Data in tables may appeared "cramped" as if needing more space. I can add space to my table by utilizing the cellspacing and cellpadding attributes in the opening table tag. You should use them even if the values are "0".

Same table with cellspacing. Internal borders are thicker and there is more space between cells.

Bright Birds
Cardinals Scarlet Tanagers
Blue Jays Blue Birds
Hummingbirds Baltimore Orioles

Cellpadding makes the space larger between the cell walls and data. Same table with cellpadding added.

Bright Birds
Cardinals Scarlet Tanagers
Blue Jays Blue Birds
Hummingbirds Baltimore Orioles

The following table utilizes all the attributes described above.

Bright Birds
In the USA
Cardinals Scarlet Tanagers
Blue Jays Blue Birds
Hummingbirds Baltimore Orioles



More Table Modifications

Width, used in the opening tag, creates an interesting and useful appearance. I can create one column and gain control of the width of a table.In the following example, the column width is 220 pixels.


This is a narrow table without a border. It can be used to create an even border on the page or to create columns on the page. Use the align attribute plus the value "left", "center", or "right" within the <td> tag. I will not need to use the center tag set if I use < td align="center".>

A person can easily manipulate text in a percentage based table. A table defined by percentage-based width will occupy that percentage of the browser screen despite the viewer's screen size. Images and text will rearrange themselves. A table width of width="100%" will occupy 100% of the screen. Width set in pixels will only have that many pixels despite what resolution the viewer has on his screen. Example: A width of 300 pixels will only occupy half the screen when the resolution is set for 600 pixels.

Both have their uses. Try to incorporate both. If I do not set a width, the table will break naturally to accommodate the various resolutions used by the viewers.

Remember:  Oftentimes it is easier to work with a table when it has a border or a frame around it. Use <table border="1">. Also, remember to set cellspacing and cellpadding values. Change the border value back to "0" when satisfied with the table.

Use the non-breaking space character to keep an even number of cells in table rows: <td>&nbsp;</td>.



Email J-Anna




Welcome Page

Week One

Week Two

Week Three

Hosted by www.Geocities.ws

1