HTML Col Attribute - Stack Overflow

I was just wondering if that by default a HTML <table> element implicitly applies the attribute scope="col" to the first group of <th> elements contained within the <thead> element?

When I render the first set of HTML below in a browser it seems to automatically detect that the <th> cells for Jan, Feb, March, April etc are headers for a column. So is it the case the scope="col" does not need adding to the markup as it will be automatically rendered this way?

<table> <caption>2009 Employee Sales by Department</caption> <thead> <tr> <th></th> <th>Jan</th> <th>Feb</th> <th>March</th> <th>April</th> <th>May</th> <th>June</th> </tr> </thead> <tbody> <tr> <th scope="row">Firefox</th> <td>37.1</td> <td>36.6</td> <td>36.3</td> <td>35.8</td> <td>35.2</td> <td>34.4</td> </tr> </tr> </tbody> </table>

This second set of markup includes scope="col" added to the tags for Jan, feb, March April etc. Is it necessary? As the example above seems to render these <th> as columns anyway without scope"col".

I am aware that the scope attribute has no visual effect in ordinary web browsers, but can be used by screen readers. So should it be added for the purpose of better semantic markup and accessibility?

<table> <caption>2009 Employee Sales by Department</caption> <thead> <tr> <th scope="col"></th> <th scope="col">Jan</th> <th scope="col">Feb</th> <th scope="col">March</th> <th scope="col">April</th> <th scope="col">May</th> <th scope="col">June</th> </tr> </thead> <tbody> <tr> <th scope="row">Firefox</th> <td>37.1</td> <td>36.6</td> <td>36.3</td> <td>35.8</td> <td>35.2</td> <td>34.4</td> </tr> </tr> </tbody> </table>

Từ khóa » Html Col Scope