CHAPTER 2 WORKING WITH
TABLES
Tables are a powerful
tool for presenting tabular data and for laying out text and graphics on an
HTML page. A table consists of one or more rows; each row consists of one or
more cells. Although columns aren’t usually explicitly specified in HTML code,
Dreamweaver allows you to manipulate columns as well as rows and cells.
After you create a
table you can easily modify both its appearance and structure. You can do any
of the following:
Note: Many designers use tables to lay out web
pages. Dreamweaver provides two ways to view and manipulate tables: Standard
view, in which tables are presented as a grid of rows and columns, and Layout
view, which allows you to draw, resize, and move boxes on the page while still
using tables for the underlying structure (see Laying
Out Pages in Layout View).
This chapter contains
these sections:
Use the Insert bar or
the Insert menu to create a new table. For information on creating accessible
tables in Dreamweaver, see Authoring
for accessibility.
To insert a table:
Note: If your document contains no content, then the only place you can place the
insertion point is at the beginning of the document.
The Insert Table dialog box appears.
For more information, see Setting
the Insert Table dialog box options.

You can add text and
images to table cells the same way that you add text and images outside of a
table.
For more information,
see Inserting
and Formatting Text and Inserting
Images.
When you add or edit
content in your table, you can save time by using the keyboard to
navigate the table.
To move from one cell to another using the keyboard, do
any of the following:
Pressing Tab in the last cell of a table automatically adds
another row to the table.
Tabular data that has
been created in another application (such as Microsoft Excel) and saved in a
delimited text format (with items separated by tabs, commas, colons,
semicolons, or other delimiters) can be imported into Dreamweaver and formatted
as a table.
To import table data:
The Import Tabular Data dialog box appears.

For more information, see Setting
the Import Tabular Data dialog box options.
You can select an
entire table, row, or column at once. You can also select a contiguous block of
cells within a table. After you’ve selected a table or cells, you can do the
following:
You can also select
multiple nonadjacent cells in a table and modify the properties of those cells.
You cannot copy or paste sets of nonadjacent cells.
To select an entire table, do one of the following:
table tag in the tag selector at the lower
left corner of the Document window.table tag in the Tag Inspector.Selection handles appear on the selected table’s lower and right edges.

To select rows or columns:

To select a single cell, do one of the following:
td tag in the tag selector at the lower
left corner of the Document window.Tip: Choose Edit > Select All again when a cell is selected to select
the entire table.
td tag in the Tag Inspector.To select a line or a rectangular block of cells, do one
of the following:
All of the cells within the linear or rectangular region defined by the two
cells are selected.

To select nonadjacent cells:
Control-click
(Windows) or Command-click (Macintosh) the cells, rows, or columns you
want to select.
If each cell, row, or
column you Control-click or Command-click isn’t already selected, it’s
added to the selection. If it is already selected, it’s removed from the
selection.
You can change the
appearance of tables by setting properties for the table and its cells or by
applying a preset design to the table. See Viewing
and setting table properties, Viewing
and setting cell, row, and column properties, and Using
a design scheme to format a table.
To format text in
tables, you can apply formatting to selected text or use styles. See Inserting
and Formatting Text.
When formatting
tables in Design view, you can set properties for the entire table or for
selected rows, columns, or cells in the table. When a property, such as
background color or alignment, is set to one value for the whole table and
another value for individual cells, cell formatting takes precedence over row
formatting, which in turn takes precedence over table formatting.
The order of
precedence for table formatting is:
For example, if you
set the background color for a single cell to blue, and then set the background
color of the entire table to yellow, the blue cell does not change to yellow,
since cell formatting takes precedence over table formatting.
Note: When you set properties on a column,
Dreamweaver changes the attributes of the td tag corresponding to each cell in the column.
When a table is
selected, the Property inspector lets you view and change table properties.
To view table properties:
To view all table properties:
If the Property
inspector isn’t expanded, click the expander arrow in the lower right corner to
see all properties.

To format a table in the Property inspector:
For more information, see Setting
table properties.
Using
a design scheme to format a table
When a cell or a set
of cells is selected, the Property inspector allows you to view and change the
cell properties.
Note: When you set properties on a column,
Dreamweaver changes the attributes of the td tag corresponding to each cell in the column.
When you set certain properties for a row, however, Dreamweaver changes the
attributes of the tr tag rather than changing the attributes of each td tag in the row, When you’re applying the
same format to all the cells in a row, applying the format to the tr tag produces cleaner, more concise HTML
code.
To view table-element properties:
To view all cell, row, or column properties:
If the Property
inspector isn’t expanded, click the expander arrow in the lower right corner to
see all properties.

To format table elements in the Property inspector:
For more information, see Setting
cell, row, and column properties.
Use the Format Table
command to quickly apply a preset design to a table. You can then select
options to further customize the design.
Note: Only simple tables can be formatted using
preset designs. You can’t use these designs to format tables that contain
merged cells (colspan or rowspan), column groups, or other unusual
formatting that keeps the table from being a simple rectangular grid of cells.
To use a preset table design:
The Format Table dialog box appears.

For more information, see Setting
the Format Table dialog box options.
You can resize an entire
table or individual rows and columns. When you resize an entire table, all of
the cells in the table change size proportionately.
Note: If a table’s cells have explicit widths or
heights specified, resizing the table changes the visual size of the cells in
the Document window but does not change the specified widths and heights of the
cells.
To resize a table:
Changing
column widths and row heights
You can change the
width of a column or the height of a row by using the Property inspector or by
dragging the borders of the column or row. You can also change cell widths and
heights directly in the HTML code using Code view.
If you have trouble
resizing, you can clear the column widths or row heights and start over.
Tip: You can specify widths and heights as
either pixels or percentages, and you can convert from pixels to percentages
and back. For more information, see Viewing
and setting table properties.
To resize a column or a row visually, do one of the
following:
If the column is not the rightmost column of the table, the adjacent
column’s width also changes, keeping the same overall table width. If the
column is the rightmost column, the whole table’s width changes, and all of the
columns grow wider or narrow proportionately.
To set a column’s width or a row’s height using the
Property inspector:
For more information, see Setting
cell, row, and column properties.
To clear all set widths or heights:
To add and remove
rows and columns, use the commands in the Modify > Table submenu.
Tip: Pressing Tab in the last cell of a table
automatically adds another row to the table.
To add rows or columns:
The Insert Rows or Columns dialog box appears.
For more information, see Setting
the Insert Rows or Columns dialog box options.
To delete a row or column:
Tip: Alternatively, you can select a complete
row or column and then choose Edit > Clear or press Delete; the entire
row or column is removed from the table.
To add or delete rows or columns using the Property
inspector:
Dreamweaver adds and removes rows at the bottom of
the table.
Dreamweaver adds and removes columns at the right
side of the table.
Note: Dreamweaver does not warn you if you are deleting rows and columns that
contain data.
Use the Property
inspector or the commands in the Modify > Table submenu to
split or merge cells. You can merge any number of adjacent cells—as long
as the entire selection is a line or a rectangle of cells—to produce a single
cell that spans several columns or rows. You can split a cell into any number
of rows or columns, regardless of whether it was previously merged. Dreamweaver
automatically restructures the table (adding any necessary COLSPAN or ROWSPAN attributes) to create the specified
arrangement.
In the following
illustration, the cells in the middle of the first two rows have been merged so
that they span two rows.

As an alternative
approach to merging and splitting cells, Dreamweaver also provides tools for
increasing and decreasing the number of rows or columns spanned by a cell.
To merge two or more cells in a table:
In the following illustration, the selection is a rectangle of cells, so
the cells can be merged.

In the following illustration, the selection is not a rectangle, so the
cells can’t be merged.

The contents of the individual cells are placed in the resulting merged
cell. The properties of the first cell selected are applied to the merged cell.
To split a cell:
For more information, see Setting
the Split Cell dialog box options.
To increase or decrease the number of rows or columns
spanned by a cell:
A nested table is a
table inside a cell of another table. You can format a nested table as you
would any other table; however, its width is limited by the width of the cell
in which it appears.

To nest a table within a table cell:
You can cut, copy, or
paste a single table cell or multiple cells at once, preserving the cells’
formatting.
You can paste cells
at the insertion point or in place of a selection in an existing table. To
paste multiple table cells, the contents of the Clipboard must be compatible
with the structure of the table or the selection in the table in which
the cells will be pasted.
To cut or copy table cells:
In the following illustration, the selection is a rectangle of cells, so
the cells can be cut or copied.

In the following illustration, the selection is not a rectangle, so the
cells can’t be cut or copied.

If you selected an entire row or column and you choose Edit > Cut,
the entire row or column is removed from the table (not just the contents of
the cells).
To paste table cells:
Note: If you have less than a full row or column of cells in the clipboard, and
you click in a cell and then paste the cells from the clipboard, the cell you
clicked in and its neighbors may (depending on its location in the table) be
replaced with the cells you are pasting.
If you are pasting entire rows or columns into an existing table, the rows
or columns are added to the table. If you are pasting an individual cell, the
contents of the selected cell are replaced. If you are pasting outside a table,
the rows, columns, or cells are used to define a new table.
To remove cell content but leave the cells intact:
Note: If only complete rows or columns are
selected when you choose Edit > Clear or press Delete, the entire rows
or columns—not just their contents—are removed from the table.
To delete rows or columns that contain merged cells:
You can sort the rows
of a table based on the contents of a single column. You can also perform
a more complicated table sort based on the contents of two columns.
You cannot sort
tables that contain COLSPAN or ROWSPAN attributes—that
is, tables that contain merged cells. (For more information, see Splitting
and merging cells.)
To sort a table:
The Sort Table dialog box appears.
For more information, see Setting
the Sort Table dialog box options.