The following is a basic HTML table that can be used for presenting information. This should be the “first choice” when tabular information is to be conveyed on the TAS website.
Table Caption
| RowHeading |
$20,000 |
$30,000 |
$5,000 |
| RowHeading |
Text Data |
More Text |
More Text |
The following are methods that the table HTML must be modified to create the styling presented above:
- Include a
<caption> element in the <tbody> section, before any <tr>. This includes the bolded “heading” for the whole table. Including it inside the <table> element ensures that it describes the entire table to screenreaders.
- Add an attribute of
style="width:100%" to the <table> element, to force it to span the width of the page container. This is optional, if it is desired to have a narrower table.
- Add a class of “blog” to the
<table> element – this sets the table borders to collapsed, and colors them according to the TAS web palette. It also ensures the other classes are appropriately picked up in the CSS.
- Add a class of “header” to each
<th> element in the top row. This ensures that they get a background color from the TAS web palette.
- For any left column header cell, make sure it is a
<th> element, but add a class of “left” instead of “header” to it. This ensures that it does NOT get the background shading, and the text is aligned to the left of the cell.
- Unless your table only has one row OR column of headers; ensure each header cell has a
scope attribute. For example; if both the first row and first column are headers, you need scope attributes, like in the table above.
- Add an attribute of
style="width: __%;" on each <th> in the first row, where the highlight is a number. The percentage should be appropriate to flex the size of the table column. This gives control over the columns in design. Omitting any width on the <th> elements will let them flex based upon the widest content without a space. Content will wrap inside the cells (<th> or <td>) at any space character, without a set width.
Each of these are optional but are the standard for basic tables on the TAS website.