Producing web pages
* HTML CSS DHTML XHTML A to Z of tags        Accessibility          Design

<table>

<table
align=left|center|right|justify
background=url
bgcolor=colour
border=n
bordercolor=colour
bordercolordark=colour
bordercolorlight=colour
cellpadding=n
cellspacing=n
class=type
clear=left|right|all|no
cols=n
dir=ltr|rtr
frame=frame-type
height=n
id=value
lang=language
nowrap
rules=rule-type
summary=text
style=style
title=text
valign=top|middle|bottom|baseline
width=n
</table>

Defines a table. Use the <tr>, <td>, and <th> tags inside the <table> tag to create the rows, columns, and a heading. The end-tag is required.

The optional <thead>, <tbody>, <tfoot>, <colgroup>, and <col> tags can be used to organise a table and apply attributes across columns and groups of columns.

Attributes

align=left|center|right|justify

Specifies the table alignment. The default is left.

Value…

Description…

left

The table is left-aligned

center

The table is centred on the page

right

The table is right-aligned. If the table is less than the width of the window, text following the table wraps along the left side of the table

justify

The table fits the left and right margin definitions

background=url

Specifies a background picture. The picture is tiled behind the text and graphics in the table, table head, or table cell.

bgcolor=colour

The background colour. Enter a hexadecimal, a red-green-blue colour value or a predefined colour name. See Using colour.

border=n

Sets the size, in pixels, of the table border. The default is zero (no border).

bordercolor=colour

The border colour. Must be used with the border attribute. Enter a hexadecimal, a red-green-blue colour value or a predefined colour name. See Using colour

bordercolordark=colour

Sets independent border colour control over one of the two colours used to draw a 3-D border, opposite of bordercolorlight. Must be used with the border attribute. Enter a hexadecimal, a red-green-blue colour value or a predefined colour name. See Colour.

bordercolorlight=colour

Sets independent border colour control over one of the two colours used to draw a 3-D border, opposite of bordercolordark. Must be used with the border attribute. Enter a hexadecimal, a red-green-blue colour value or a predefined colour name. See Colour.

cellpadding=n

Sets the amount of space, in pixels, between the sides of a cell and its contents.

cellspacing=n

Sets the amount of space, in pixels, between the frame (exterior) of the table and the cells in the table.

clear=no|left|right|all

Formats text following the table. The default is NO.

Value…

Description…

no

Text appears immediately after the table

left

Text appears as the first left-aligned line after the table

right

Text appears as the first right-aligned line after the table

all

 

class=type

Indicates the class to which the tag belongs. You can use the class attribute in a style sheet to create different styles that you want apply to a single HTML tag. For example, you might create three different styles for a <table> tag. See Using the class attribute as a selector for more details.

cols=n

Sets the number of columns in the table. If given, this may speed up processing of tables, especially lengthy ones.

dir=ltr|rtr

Specifies the direction of text. This can be left-to-right (ltr) or right-to-left (rtl). For example, English characters are presented left-to-right, Hebrew characters are presented right-to-left.

frame=frame-type

Specifies which sides of a frame (outer borders) are displayed. The frame-type can be one of these values:

Value…

Description…

border

Displays a border on all four sides of the table. This is the default

void

Removes all outside table borders

above

Displays a border on the top side of the table

below

Displays a border on the bottom side of the table

hsides

Displays a border on the top and bottom sides of the table

lhs

Displays a border on the left-hand side of the table

rhs

Displays a border on the right-hand side of the table

vsides

Displays a border on the left and right sides of the table

box

Displays a border on all sides of the table frame

height=n

Sets the height of the table in pixels or as a percentage of the window. To set a percentage, the n must end with a percent sign (%).

id=value

Specifies a unique name for the tag. No two tags can have the same id on a single page. The value must begin with a letter followed by any alphanumeric character, a hyphen, an underscore, a colon or a full stop. You use it to reference a unique style for a tag or to manipulate the tag with a script.

lang=language

Specifies which language the <table> tag uses. You can enter any valid ISO standard language abbreviation, for example, “en” for English, “de” for German and so on. For example, <span lang="es">hola! como esta?</span>.

This attribute helps search engines understand different languages as different languages rather than just misspelled English. It may also help spelling and grammar checkers and allow speech synthesizers to use language-dependent pronunciation rules.

nowrap

Keeps table rows from wrapping if they extend beyond the right margin.

rules=rule-type

Specifies which dividing lines (inner borders) are displayed. You can only use rules in tables with the <thead>, <tbody> and <tfoot> tags set. The rule-type can be one of these values:

Value…

Description…

none

Removes all interior table borders. This is the default

groups

Displays horizontal borders between all table groups. Groups are specified by the <thead>, <tbody>, <tfoot>, and <colgroup> tags

rows

Displays horizontal borders between all table rows

cols

Displays vertical borders between all table columns

all

Displays a border on all rows and columns

summary=text

Describe the purpose and/or structure of the table. The overview is particularly helpful to users of non-visual browsers.

style=style

Specifies style information. See Style sheets for more information.

title=text

For information only. Some browsers display the title when you move the mouse over the tag (like a tool tip).

valign=top|middle|bottom|baseline

Specifies the vertical table alignment. The default is top.

Value…

Description…

top

The table is aligned at the top

middle

The table is vertically aligned at the middle

bottom

The table is vertically aligned with the bottom

baseline

The table is aligned with the text baseline

width=n

Sets the width of the table in pixels or as a percentage of the window. To set a percentage, the n must end with a percent sign (%).