//Add Summary if not present $('table:not(:has(summary))').attr('summary', 'This is a table for forum replies'); //Add caption if not present $('table:not(:has(caption))').prepend('<caption>Reply to forum posts here</caption>'); //Add column scope if not present $('thead tr > th:not(:has(scope))').attr('scope', 'column'); //Add row scope to if not present $('tbody tr > th:not(:has(scope))').attr('scope', 'row');
<table> <thead> <tr> <th>This is a header</th> <th>This is a header</th> <th>This is a header</th> <th>This is a header</th> </tr> </thead> <tbody> <tr> <th>Test</th> <td>Test</td> <td>Test</td> <td>Test</td> </tr> <tr> <th>Test</th> <td>Test</td> <td>Test</td> <td>Test</td> </tr> </tbody> </table>
table{ width:100%; } thead tr > th[scope="column"]{ background:#ccc; } tbody tr > th[scope="row"]{ background:#89b958; } td{ border:1px solid #ccc; }