Because tables hold data, it's useful to label the columns and/or rows that are holding the information. That way, both the sighted viewer and the non-graphical environment understand better what the table is trying to communicate.
We'll use the th
(table header) tag to define a set of header cells in a table that contains information about HTML color names. The screenshot in this exercise will show you what your table will look like, so you can see what you're attempting to build. Build your table as follows. It will have 4 columns and 10 rows. Put a border of 1 on this table.
scope
attribute):
When you are putting in the background-color, alternate using the color name, the hexidecimal and rgba(r, g, b, a) syntax for specifying a color. This gives you experience using all three.
The purpose of the non-breaking space is to have some content in the td
tags even though all we want to see is the background color, not any text information. You shouldn't ever have empty tags. Compare the following:
<td></td>
(empty tag)<td> </td>
(not empty tag).
Why don't we put any data in the final column? Color is only presentational, so there is nothing for the non-graphical environment to "see." You won't need to put character entities in any table other than this one, because any table you make probably has data in each cell. I put this in here as an example of a legitimate use of the non-breaking space character entity.
Color Name | RBG Value | Hexadecimal Value | Color Swatch |
---|---|---|---|
grey | 84, 84, 84 | #545454 | |
silver | 192, 192, 192 | #c0c0c0 | |
blue | 0, 0, 255 | #0000ff | |
yellow | 255, 255, 0 | #ffff00 | |
pink | 255, 192, 203 | #ffc0cb | |
purple | 128, 0, 128 | #800080 | |
orange | 255, 165, 0 | #008800 | |
green | 0, 128, 0 | #545454 | |
black | 0, 0, 0 | #000000 |
This table will use table headers, rowspan, and background colors to make a visualization of a schedule. See the screenshot and emulate this as closely as you can.
Day of Week | Times | Classroom Assistant |
---|---|---|
Monday | 10:30 - 11:30am | Jane Doe |
Tuesday | 8:00 - 10:00am | John Smith |
Wednesday | 12:30 - 1:30pm | Sally Jones |
3:00 - 4:00pm | Robin Davis | |
Thursday | 11:30am - 12:30pm | Sam Roberts |
This table will have images as some of its table data. The screenshot will help you locate the content in the proper place, and communicate where table headers are being used.
Viburnum Variety | Foliage | Flower | Fruit |
---|---|---|---|
Guelder rose | |||
Burkwood | |||
Southern Arrowwood |
thead
and tbody
Let's go back and add a table header to the tables. Once we add a table header, we'll want to also mark up the table body. The thead
and tbody
are important for usability and styling; they don't "show up" by default.
caption
to the tablesLet's go back and add a caption to the tables. The caption goes at the top of the table, before the thead
. You can control where the caption displays with a style. The property is caption-side
and the value you want is bottom
, if you'd like to swap the caption from the top of the table to the bottom of the table. Move at least one of your captions to the bottom of the table.
The border attribute will cause an error on every table that uses it, but otherwise there should be no errors.