OAA TABLES_2: Data tables must use th elements
Rulesets
- WCAG 2.0 Requirement 1.3.1 Info and Relationships
- Status: Accepted
- Severity: Violation
- Priority: Priority 1
- IITAA 1.0 11.1 Identify a header cell for each column and row in simple data tables.
- Type:
- Severity: Violation
- Priority: Priority 1
- Status: Accepted
Markup References
Validation Code
Message
Data tables must use th elements to indicate header cells for the first cell in all the columns or rows.
Dependencies
None
Context
.dataTable
Parameters
None
Code
function (ruleContext) {
var passed = false;
var node = ruleContext;
var r,c;
var thColCount=0,thRowCount = 0;
//contains data from tablenode.tHead.rows & tablenode.tFoot.rows
if (node.rows[0].cells.length > 1) {
for (c=0; c < node.rows[0].cells.length; c++) {
// the first cell in each column has a header
if (node.rows[0].cells[c].tagName.toLowerCase() == 'th' && xbrowser.getTextContent(node.rows[0].cells[c]).normalizeSpacing() != '') {
thColCount++;
} // endif
} // endfor
if (node.rows[0].cells.length == thColCount) {
passed = true;
} // endif
} // endif
if (!passed) {
if (node.rows.length > 1) {
for (r=0; r < node.rows.length; r++) {
if (node.rows[r].cells[0].tagName.toLowerCase() == 'th' && xbrowser.getTextContent(node.rows[r].cells[0]).normalizeSpacing() != '') {
thRowCount++;
} // endif
} // endfor
if (node.rows.length == thRowCount) {
passed = true;
} // endif
} // endif
if (node.rows[0].cells.length-1 == thColCount && node.rows.length-1 == thRowCount) {
passed = true;
} // endif
} // endif
return new ValidationResult(passed, [ruleContext], '', '', []);
}//endfunction
>
var passed = false;
var node = ruleContext;
var r,c;
var thColCount=0,thRowCount = 0;
//contains data from tablenode.tHead.rows & tablenode.tFoot.rows
if (node.rows[0].cells.length > 1) {
for (c=0; c < node.rows[0].cells.length; c++) {
// the first cell in each column has a header
if (node.rows[0].cells[c].tagName.toLowerCase() == 'th' && xbrowser.getTextContent(node.rows[0].cells[c]).normalizeSpacing() != '') {
thColCount++;
} // endif
} // endfor
if (node.rows[0].cells.length == thColCount) {
passed = true;
} // endif
} // endif
if (!passed) {
if (node.rows.length > 1) {
for (r=0; r < node.rows.length; r++) {
if (node.rows[r].cells[0].tagName.toLowerCase() == 'th' && xbrowser.getTextContent(node.rows[r].cells[0]).normalizeSpacing() != '') {
thRowCount++;
} // endif
} // endfor
if (node.rows.length == thRowCount) {
passed = true;
} // endif
} // endif
if (node.rows[0].cells.length-1 == thColCount && node.rows.length-1 == thRowCount) {
passed = true;
} // endif
} // endif
return new ValidationResult(passed, [ruleContext], '', '', []);
}//endfunction
>