Portland Community College | Portland, Oregon Portland Community College

Tables

Use tables to display tabular data only, never for layout!

Each column in a table must have a heading, and when necessary rows can have headings listed down the left side. Tables can also have a caption, or allow alphabetical sorting by heading.

Using tables in WordPress requires a plugin. Get approval from the Web Team to use it.

Styling

Table headings have gray shading (column headings are slightly darker than row headings), and there is a light gray divider between all table cells. Table text is slightly smaller than body text.

Responsive behavior

Tables aren’t truly responsive. Once the screen becomes too narrow for the table, a shadow appears along the left and right sides, showing users that there’s more table to see off the screen that they can scroll horizontally to see. Tables don’t break the responsive layout or let the text flow outside the table cells.

Development info
  • Stylesheet location: /source-v6/styles/components/_tables.scss
  • Use <table class="turntable"> for a sortable table.
  • All forms should have a <caption> for accessibility reasons
    • You can use <caption class="visually-hide"> if you don’t want the caption to be visible.
    • Captions can have a Font Awesome icon before the text, right after the opening <caption> tag.
    • <table summary=""> is deprecated, use <caption> instead.
  • All forms should have a <thead> that contains the column headings and a <tbody> that contains the rest of the form cells.
  • All column and row headings should use the table header tag (<th>), and include either scope="col" or scope="row" depending on the header type.
  • Don’t ever leave the first column heading blank, even if there are row headings. This is bad for accessibility.
  • Don’t add other style elements to the table cells, such as valign, width, height, bgcolor, or style="".
  • Javascript adds the wrapper and shadow divs for responsiveness – don’t add them manually.
  • <table>
      <caption>Brief description of the table contents</caption> <!-- can include class="visually-hide" if you don't want it visible -->
      <thead>
        <tr>
          <th scope="col"></th>
          <th scope="col"></th>
          <th scope="col"></th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <th scope="row"></th> <!-- or td if no row headings -->
          <td></td>
          <td></td>
        </tr>
        <tr>
          <th scope="row"></th><!-- or td if no row headings -->
          <td></td>
          <td></td>
        </tr>
      </tbody>
    </table>

Table examples

Regular table (with an optional footer)
Regular table
Column heading Column heading Column heading Column heading
Row heading Data Data Data
Row heading Data Data Data
Row heading Data Data Data
Footer heading Data Data Data
Sortable table
Sortable table
Column heading Column heading Column heading Column heading
Row heading 1 Data 1 Data 1 Data 1
Row heading 2 Data 2 Data 2 Data 2
Row heading 3 Data 3 Data 3 Data 3
Table with a visible caption
clockTable with a visible caption
Column heading Column heading Column heading Column heading
Row heading Data Data Data
Row heading Data Data Data
Row heading Data Data Data