web design logo

  • Design
    • Introduction
    • Visual Design
    • Web Writing
    • Accessibility
  • XHTML/CSS
    • Introduction
    • Coding Basics
    • Color
    • CSS
    • Forms
    • Images
    • Image Maps
    • Javascript
    • Links
    • Lists
    • Tables
    • XHTML Videos
  • Dreamweaver
    • Introduction
    • Videos
  • Fireworks
    • Introduction
    • Image Effects
    • Logos
    • Buttons
    • Animation
    • Videos
  • Photoshop
    • Introduction
    • Backgrounds
    • Image Effects
    • Logos
    • Buttons
    • Videos
  • Links
  • About Me
  • Home
 

TABLES

Basic Examples    ~    Cafe Menu (colspans and rowspans)

Tables allow us to display information in columns, much as tables are used in word processing for charts and graphs. Tables are a little tricky to code at first...

Create your table on paper first - it will be much easier to "code"!

HTML tables have:

rows -- horizontal
columns -- vertical
cells -- the intersection of a row and column

Tables must have the same number of cells in each table row.

Borders can be visible or transparent and can vary in thickness.

Example

This Table has 3 rows and 2 columns:
Cellpadding of 2
Cellspacing of 2

<table>

<tr>
    <td>1st Row & 1st Column</td>
    <td>1st Row & 2nd Column</td>
</tr>

<tr>
    <td>2nd Row & 1st Column</td>
    <td>2nd Row & 2nd Column</td>
</tr>

<tr>
    <td colspan="2">Third Row & Combined Column</td>
</tr>

</table>

1st Row & 1 Column

1st Row & 2nd Column
2nd Row & 1st Column 2nd Row & 2nd Column
 3rd Row & Combined Column

Tips:

You can create a blank cell:
    <td>&nbsp;</td>
you can have a cell "span" several columns to equal the same number of cells per row.
    <td colspan="2">

Sometimes you want to have more than one line of text in a cell. Since browsers ignore the ENTER key, you break the line by adding <br / > where you want the line to stop.

Table Summary:

Provides alternative text to the table for those that are blind or have text-only browsers.

<table summary="table example">

Enhancements:

Axis:

This tag provides blind or text-browser users a brief description of cell data.

<td axis="description of cell">Cell Data</td>

Scope:

Scope allows you to transfer attributes from one cell to other cells in a table without retyping the attributes.

· Col - sets the rest of the column
· Colgroup - sets the rest of the colgroup
· Row - sets the rest of the row
· Rowgroup - sets the rest of the rowgroup

<table cellpadding="5" cellspacing="5" summary="table of activities" >

<tr>
  <th>Monday</th>
  <th>Tuesday</th>
  <th>Wednesday</th>
</tr>

<tr>
  <td>Monday's Book-it</td>
  <td>Bridge</td>
  <td>Solitares</td>
</tr>

<tr>
  <td>Salad</td>
  <td>Home cooking</td>
  <td>Brunch</td>
</tr>
</table>

Displays as:

Monday Tuesday Wednesday
Monday's Book-it Bridge Solitares
Salad Home cooking Brunch

Back to the Top

©2001, Linda Baker ~ Last Updated: January 28, 2009