scope-attr-valid
Description
The scope attribute has to be used in tables as follows:
- The value of the
scopeattribute should be eitherroworcol. - All <th> elements should have a
scopeattribute. - In HTML4, the
scopeattribute should be used only onthandtdelements. - In HTML5, the
scopeattribute should be used only onthelements.
Example
In the following example, the first column and the first row don’t have a scope attribute defined in the <th> element. Without a scope attribute, screen readers and other assistive technologies find it difficult to understand the relationships between the table elements. So, the following code breaks the scope-attr-valid rule.
In contrast, the following code snippet uses the scope attribute on all th elements. This makes it easy for screen readers and other assistive technologies to understand the relationships between the table elements. So, this code snippet doesn’t break the scope-attr-valid rule.
How to fix?
You can follow these steps to fix issues if this rule gets flagged:
- Check if all the <th> elements have a
scopeattribute defined. If not, add it. - Check if the value of the
scopeattribute is anything other thanroworcol. If so, change it. - For HTML4, check if you have used the
scopeattribute anywhere other thanthortdelements. If so, remove it. - For HTML5, check if you have used the
scopeattribute anywhere other thanthelements. If so, remove it.
References
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
Thank you for your valuable feedback!