Attributes

Contact Us or call 1-877-932-8228
Attributes

Attributes

The following tables list attributes that have been deprecated in the current HTML standards. They are presented here for backwards compatibility with older browsers. Internet Explorer 7 and earlier do not support all of the latest CSS settings that replace these obsolete attributes. Later in this course is a lesson on using CSS for styling. Using CSS is the recommended way of styling tables.

<table> Attributes
Attribute Description
width sets the width of the table in pixels or percentage
border sets the width of the border of the table
cellspacing sets the distance between cells in pixels
cellpadding sets the distance between cell content and the cell border in pixels
summary used to provide a longer description of the table for screenreaders
<tr> Attributes
Attribute Description
align aligns the content in the cells in the table row horizontally (left, center, or right)
valign aligns the content in the cells in the table row vertically (top, middle, or bottom)
<td> and <th> Attributes
Attribute Description
align aligns the content in the cells in the table row horizontally (left, center, or right)
valign aligns the content in the cells in the table row vertically (top, middle, or bottom)
colspan indicates the number of columns the cell should span
rowspan indicates the number of rows the cell should span

The table in the page below shows these attributes in use:

Code Sample:

Tables/Demos/TableHomeRunsFormatted.html
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Home Run Hitters</title>
</head>
<body>
<table width="500" border="2" cellpadding="1" cellspacing="3">
<caption>All-time Home Run Record</caption>
<tr>
	<th>Player</th>
	<th>Home Runs</th>
	<th>Team</th>
</tr>
<tr>
	<td>Hank Aaron</td>
	<td align="right">755</td>
	<td>Braves</td>
</tr>
<tr>
	<td>Barry Bonds</td>
	<td align="right">748</td>
	<td>Giants</td>
</tr>
<tr>
	<td>Babe Ruth</td>
	<td align="right">714</td>
	<td>Yankees</td>
</tr>
<tr>
	<td>Willie Mays</td>
	<td align="right">660</td>
	<td>Giants</td>
</tr>
</table>
</body>
</html>

This screenshot below shows how this table would be rendered:Rendered Formatted Table

Next