170 likes | 342 Views
8 Tables. Learning Outcomes. Create a Table Apply Attributes to Format Tables Increase the Accessibility of a Table Style a Table with CSS. <pre>. <pre>…</pre> Preformatted Text Presents Blocks of Text in Fixed-width Font Renders Multiple Spaces. Tables.
E N D
8 Tables
Learning Outcomes • Create a Table • Apply Attributes to Format Tables • Increase the Accessibility of a Table • Style a Table with CSS
<pre> • <pre>…</pre> • Preformatted Text • Presents Blocks of Text in Fixed-width Font • Renders Multiple Spaces
Tables • Used on Web Pages to Organize Tabular Information • Composed of Rows & Columns • Similar to a Spreadsheet • Table Cell is Intersection of a Specific Row & Column • Configured with table, tr, & td Elements
<table> • <table>…</table> • Structure to Contain & Align Content • Attributes • border=“” or “1” • Sets Thickness of Borders Displayed for Table Cells • Attribute Set to “” Will Make Borders “Invisible”
<colgroup> • <colgroup>…</colgroup> • Defines Groups of Table Columns for Formatting • Only Valid Inside <table> • Attributes • span=“#” • Specifies Number of Columns <colgroup> Should Span
<col> • <col /> • Defines One or More Columns of Table for Formatting • Only Valid Inside <table> or <colgroup> • Attributes • span=“#” • Specifies Number of Columns the Column Should Span
<tr> & <td> • <tr>…</tr> • Defines a Row in a Table • <td>…</td> • Defines Table Data (a Cell) in a Row • Table Data Cells Must Only Appear Within Table Rows
<td> • Attributes • colspan=“#” • Specifies How Many Columns the Cell Overlaps • rowspan=“#” • Specifies How Many Rows the Cell Overlaps
Nesting Tables • Nested Tables Must Reside in <td> <table> <tr> <td>Some text</td> <td> <table> <tr> <td>Table in a table</td> </tr> </table> </td> </tr> </table>
Table Accessibility • <th>…</th> • Specifies the Table Header for a Row • Identical to Table Data Cells Except: • Cells Contents are Bolded & Centered • Attributes • colspan=“#” • Specifies Number of Columns a Header Cell Overlaps • rowspan=“#” • Specifies Number of Rows a Header Cell Overlaps
Table Accessibility • <th>…</th> • Attributes • headers=“header_id” • Specifies One or More Header Cells a Cell is Related to • scope=“col | colgroup | row | rowgroup” • Specifies Whether Header Cell is a Header for a: • Column, Row, or Group of Columns or Rows
Table Accessibility • <caption>…</caption> • Attaches a Caption to a Table • Use text-align to Align the Caption • Use caption-side to Place the Caption
Table Row Groups • <thead>…</thead> • Designate Heading Section of a Table • <tbody>…</tbody> • Designate Body Section of a Table • <tfoot>…</tfoot> • Designate Footer Section of a Table
CSS & Tables • Cell Visual Control • padding • Specify Amount of Space Within Cell • border-spacing or border-collapse • Specify Amount of Space Between Cells
CSS & Tables • Cell Visual Control • :first-of-type • Applies to the first element of the specified type • :first-child • Applies to the first child of an element (CSS2 selector) • :last-of-type • Applies to the last element of the specified type
CSS & Tables • Cell Visual Control • :last-child • Applies to the last child of an element • :nth-of-type(n) • Applies to the “nth” Element of the Specified Type • Values: Number, Odd, or Even • Zebra Stripe a Table • tr:nth-of-type(even) { background-color: #eaeaea; }