welldan97
welldan97

Reputation: 3076

<th> for column headers

Is it suitable/semantic to use <th> tag for column headers. I.e. should Price, and Qty be in <th> tags for table like this?

+-------+--------+---------+--------+
|       | apples | oranges | lemons |
|-------+--------+---------+--------|
| Price | 100    | 200     | 300    |
|-------+--------+---------+--------|
| Qty   | 10     | 10      | 10     |
+-------+--------+---------+--------+

Upvotes: 1

Views: 124

Answers (2)

Quentin
Quentin

Reputation: 943460

Is it suitable/semantic to use tag for column headers.

Yes

I.e. should Price, and Qty be in tags for table like this?

Those are row headings, but still, yes.

<table>
    <tbody>
        <tr>
            <td>
            <td scope="col">apples <!-- both heading and data so use td with scope -->
        <!-- etc etc -->
            <th scope="row">Price

Upvotes: 2

Jay
Jay

Reputation: 1309

Yes,u can do this

<TABLE border="1">
<CAPTION><EM>A test table with merged cells</EM></CAPTION>
<TR><TH rowspan="2"><TH colspan="2">Average
    <TH rowspan="2">Red<BR>eyes
<TR><TH>height<TH>weight
<TR><TH>Males<TD>1.9<TD>0.003<TD>40%
<TR><TH>Females<TD>1.7<TD>0.002<TD>43%
</TABLE>

and see the link http://www.w3.org/TR/html4/struct/tables.html

Upvotes: 1

Related Questions