th scope attribute

J

JD

Is the <th> scope attribute needed for simple tables? For example, will
the following be clear for a wide range of visitors?

<table>
<tr><th>Make</th><th>Year</th></tr>
<tr><td>Ford </td><td>1987</td></tr>
<tr><td>Audi </td><td>2000</td></tr>
</table>

Or should I do:

<table>
<tr><th scope="col">Make</th><th scope="col">Year</th></tr>
<tr><td>Ford </td><td>1987</td></tr>
<tr><td>Audi </td><td>2000</td></tr>
</table>

Thanks
 
D

dorayme

JD said:
Is the <th> scope attribute needed for simple tables? For example, will
the following be clear for a wide range of visitors?

<table>
<tr><th>Make</th><th>Year</th></tr>
<tr><td>Ford </td><td>1987</td></tr>
<tr><td>Audi </td><td>2000</td></tr>
</table>

Or should I do:

<table>
<tr><th scope="col">Make</th><th scope="col">Year</th></tr>
<tr><td>Ford </td><td>1987</td></tr>
<tr><td>Audi </td><td>2000</td></tr>
</table>

Do the former. This does not apply in your case:

For a given header cell, the scope attribute tells the user agent the
data cells for which this header provides information. Authors may
choose to use this attribute instead of headers according to which is
more convenient; the two attributes fulfill the same function. The
headers attribute is generally needed *when headers are placed in
irregular positions with respect to the data they apply to*.
 
J

Jukka K. Korpela

Scripsit JD:
Is the <th> scope attribute needed for simple tables?

No, but it doesn't hurt, and it may be useful for markup documentation:
anyone (like you some years later) reading the HTML source alone, even
without understanding the natural language in it, will immediately see
that the cell is a header for a column or for a row.
For example,
will the following be clear for a wide range of visitors?

<table>
<tr><th>Make</th><th>Year</th></tr>
<tr><td>Ford </td><td>1987</td></tr>
<tr><td>Audi </td><td>2000</td></tr>
</table>

Or should I do:

<table>
<tr><th scope="col">Make</th><th scope="col">Year</th></tr>
<tr><td>Ford </td><td>1987</td></tr>
<tr><td>Audi </td><td>2000</td></tr>
</table>

Adding the scope attribute isn't very important in a case like this, but
it is good practice.

It is more important to consider the accessibility of the table as a
whole. How does it relate to text? What does it really mean? A person
using a speech browser will be in a more difficult situation, since he
does not see the table as a whole or its visual association with
anything.

Using <caption>, or maybe explanatory text before the table, or even
both is generally useful for a data table. If you think that the meaning
and purpose is self-evident from merely looking at the table, then you
might consider using the summary="..." attribute to explain them to a
user who cannot look at the table.
 
H

Harlan Messinger

JD said:
Is the <th> scope attribute needed for simple tables? For example, will
the following be clear for a wide range of visitors?

<table>
<tr><th>Make</th><th>Year</th></tr>
<tr><td>Ford </td><td>1987</td></tr>
<tr><td>Audi </td><td>2000</td></tr>
</table>

Or should I do:

<table>
<tr><th scope="col">Make</th><th scope="col">Year</th></tr>
<tr><td>Ford </td><td>1987</td></tr>
<tr><td>Audi </td><td>2000</td></tr>
</table>

If accessibility via screenreaders is your concern, several years ago I
figured out that the prevalent screenreaders even back then handled
simple tables, even with multiple levels of row or column header THs
(using colspan or rowspan, respectively, for all but the lowest level of
each) correctly without the use of either scope or headers attributes. I
also found that as soon as even one scope or headers attribute was
thrown into the table, the screenreaders would abandon their intuitive
treatment of the table and rely *only* on the special attributes, so if
your table has even a single deviation from simplicity, be prepared to
mark up the whole thing.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,102
Messages
2,570,645
Members
47,243
Latest member
CorrineCad

Latest Threads

Top