Web Development and Design Foundations with XHTML, 5th Edition

(Steven Felgate) #1

(^318) Chapter 8 Tables
The bgcolorAttribute. This deprecated attribute specifies a background color
for the table. The values can be a color name or numeric value. See the color chart at
http://webdevfoundations.net/color. An example with a background color, no border,
and cellpaddingof 10 is shown in Figure 8.11. The XHTML code for the

tag
follows:



Figure 8.10
Table with
cellpaddingset
to 10
Figure 8.11
Borderless table
using cellpadding
set to 10 along with
a background color
FAQ
Can I mix and match fixed widths and percentages?
Yes. The width attribute can be applied to table cells (
elements) as well as to the entire
table (element). If you are using a table to format an entire page, you might want a
particular column used for navigation links to have a fixed width while the entire table uses a
percentage width. As always, test your Web pages using different screen resolutions to make
sure that you achieve your desired effect.
The summaryAttribute. This attribute specifies a summary of the table contents
that can be accessed by a screen reader. The Web Accessibility Initiative (WAI) suggests
using the summaryattribute with tables containing data. For example:
summary="This table contains a birthday list. Each row provides
birthday and contact information for an individual. The columns
contain name, birthday, phone, and e-mail address.">
The titleAttribute.This attribute specifies a title of the table that can be accessed
by a screen reader. The value of the titleattribute is displayed by some browsers, such
as Internet Explorer 5 (or later), when the mouse passes over the table area. The WAI
prefers using the summary attribute or the caption element instead of the titleattribute.
Applying Attributes to Rows and Cells
Many of the
element attributes discussed above can also be applied to ,
, and tags to customize the look of your table. In particular, the bgcolor,
align, and widthattributes are most often used. The following are commonly used
WWW
Focus on Accessibility
WWW
Focus on Accessibility