scope-attr-valid
Description
The scope
attribute has to be used in tables as follows:
- The value of the
scope
attribute should be eitherrow
orcol
. - All <th> elements should have a
scope
attribute. - In HTML4, the
scope
attribute should be used only onth
andtd
elements. - In HTML5, the
scope
attribute should be used only onth
elements.
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
scope
attribute defined. If not, add it. - Check if the value of the
scope
attribute is anything other thanrow
orcol
. If so, change it. - For HTML4, check if you have used the
scope
attribute anywhere other thanth
ortd
elements. If so, remove it. - For HTML5, check if you have used the
scope
attribute anywhere other thanth
elements. 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!