bytes.zone

Scope in the TH element

Brian Hicks, December 19, 2022

The <th> (table head) element in HTML accepts a scope attribute. According to MDN, it can be one of these:

<th scope="row"> can be really useful for accessibility. Say you have a table like this:

NameText-to-speech enabledEdit student
Valencia Flowersyes<button>
Romeo Harrisonno<button>

If the "name" cells are <th scope="row">, screen readers can contextualize "yes" or "no" and the edit button when navigating between rows in a non-name column. For example, one might say something like "text-to-speech enabled, Valencia Flowers, row, yes."

If you'd like me to email you when I have a new post, sign up below and I'll do exactly that!

If you just have questions about this, or anything I write, please feel free to email me!