Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML HTML Tables Table Basics The Table Header Cell Element

Do the <th scope="row"></th> cell always must be in the first column?

I have a table that have the most important field in the second column, so I do not know if I can place the scope attribute in another column.

<table> <tr> <td>Data</td> <th scope="row">Most Important Data</th> <td>Data</td> <td>Data</td> </tr> </table>

3 Answers

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

Hiya,

Yes the scope refers to an entire row or column in a table, so this would need to be the first "cell" in your row. Remember in a table, a column is made up of one or many rows. :-)

<table>
<tr>
<th>Title</th>
 <th>Second Title</th>
</tr>
<tr>
<td> </td>
 <td> </td>
</tr>
<tr>
<td> </td>
 <td> </td>
</tr>
<tr>
<td> </td>
 <td> </td>
</tr>

Thank you.

Graeme Oxley
Graeme Oxley
8,931 Points

This is incorrect. You can have any number of "scope" definitions throughout a table. It does not HAVE to be in the first cell at all.

The point of "scope" is simply to define what information that a <th> element is intended to label. The video itself shows that you can have a <th> and "scope" anywhere in the table.

No, the scope does not need to be the first "cell". For example, U can have the following code; which is perfectly valid HTML:

<table>
 <tr>
  <th scope="col">Number</th>
  <th scope="col">Name</th>
  <th scope="col">Job</th>
 </tr>
 <tr>
  <td>1.</td>
  <th scope="row">John Doe</th>
  <td>Sales Manager</td>
</tr>
 <tr>
  <td>2.</td>
  <th scope="row">Jane Doe</th>
  <td>CEO</td>
</tr>
</table>
Ronald Lira
Ronald Lira
12,217 Points

I think the importance of the scope attribute when used within a row is to identify the key column. If you relate this to how databases are used, you usually have a key column. The values in this column should be always unique when compared against the other rows in the same column. This works like an id that can be related to the information on other cells of the same row. In conclusion, within a row, you can use any of the cells as your key, as long as you always use the same cell position for all rows.