http://developers.whatwg.org/tabular-data.html
Check into the scope attribute sometime…
A table can have a header, body, footer, and caption.
Structure rules:
District | 1st Quarter | 2nd Quarter | 3rd Quarter | 4th Quarter |
---|---|---|---|---|
Total | $2,987,987.00 | $987,987.00 | $987,987.00 | $987,987.00 |
Northern | $123,998.00 | $4,123,998.00 | $123,998.00 | $98.00 |
Eastern | $998.00 | $998.00 | $998.00 | $998.00 |
Southern | $13,998.00 | $123,998.00 | $98.00 | $4,123,998.00 |
Western | $1,998.00 | $98.00 | $4,123,998.00 | $123,998.00 |
There are a few weird things when attempting to make your table look beautiful.
<table>
. Internal elements (<tr>, <td>, <th>, <col>
, etc.) can not have margin.<colgroup>
and <col>
allow only four properties for styling: width, border, background, and visibility.The above table was styled with:
table {
border-collapse:collapse;
background: linear-gradient(top, rgba(201,200,169,1) 0%,rgba(151,217,237,1) 100%); /* W3C */
}
/* style columns */
col { /* The table was defined with only the first column getting the col element. */
width:8em;
background-color:lemonchiffon;
}
tr td:first-child { /* text in first column */
font-weight:bold;
}
td + td { /* all columns except the first */
text-align:right;
}
/* style rows */
table td, th { /*all body and header cells */
padding:5px 1em;
border:thin solid #030;
}
th { /* header - aka. the first row */
background-color:#C9C8A9;
color:#1C4D1A;
}
tfoot td {/* footer - aka. the last row */
background-color:#09C;
color:#FFF;
}
If you are only styling width, border, background or visibility, then you can target the CSS against <col> or <colgroup>. Any other CSS property must be applied to cells (<td>
) using a selector such as tr > td + td { … }
or tr td:first-child { … }
Refer to the CSS Selectors page for more information on this advanced selector.