Prev NEXT

How Web Pages Work

Changing the Table Background Color

Change the color of entire table background by using the "bgcolor" tag within the initial "table" tag:

Example:

Advertisement

A colored background can also be assigned to a row or a cell within a table. Just add bgcolor="color" to either the

or
tag to color that specific portion of the table.

例子:< tr背景= "yellow">

Table Size

The width and height of rows and columns in a table will expand automatically to fit the length of data and/or the space of the browser window. To specify a width and height, include either pixels or percentage values within the starting "table" tag:

Example:

Width and height can also be specified for an individual data cell, as opposed to the table as a whole. To do this, add width="value" to the

or
tag in question.

Again, it's a good idea to simply experiment with pixel and percentage values to find out what they look like in a browser.

Cellpadding

The "cellpadding" tag specifies (in pixels) the amount of space between the edges of each cell and the data inside each cell. Use it within the starting "table" tag:

Example 1:

Example 2:

Cellspacing

The "cellspacing" tag specifies (in pixels) the amount of space between each cell. Use it within the "table" tag:

Example 1:

Example 2:

Table Headings

To create a bold and centered "heading" for a column or row within a table, use the

tag in place of a tag in the coding for your first row.

Example:

Column 1 Column 2
A B
C D

In the next section, we'll look at alignment and cell padding.