HTML and CSS Reference
In-Depth Information
Tables dissected
You've seen four elements used to create a
single table: <table>, <tr>, <th>, and <td>. Let's
take a closer look at each one to see exactly
what role it plays in the table.
The <th> ele
ment contains one ce
ll in the heading of
your table. I
t must be inside a tab
le row.
T
he <ta
ble> tag
starts
the wh
ole thin
g
o
ff. Whe
n you w
ant a t
able, st
art her
e.
The <
/tr> ta
g ends
a row
of the
table.
<th>
Date
</th>
<table>
Diner
Rating
<tr>
</tr>
City
Date
Temp
Altitude
Population
<tr>
<tr>
<tr>
<tr>
<tr>
</tr>
</tr>
</tr>
</tr>
</tr>
Walla Walla, WA
June 15th
75
1,204 ft
29,686
4/5
Magic City, ID
June 25th
74
5,312 ft
50
3/5
Bountiful, UT
July 10th
91
4,226 ft
41,173
4/5
Last Chance, CO
July 23rd
102
4,780 ft
265
3/5
Truth or
Consequences,
NM
August 9th
93
4,242 ft
7,289
5/5
<tr>
</tr>
Why, AZ
August 18th
104
860 ft
480
3/5
Each
<tr>
element
spec
ifies a t
able ro
w.
So,
all the t
able da
ta
that
goes in
a row
is
nest
ed insid
e the <
tr>
elem
ent.
</table>
<td>
August 9th
</td>
The <
td> element contains
one data cell in your
table.
It must be inside a t
able row.