| Course weeks and topics | |
|---|---|
| 1. Intro to HTML 5 | 6. Page Layout with CSS |
| 2. First Web Page | 7. HTML Tables |
| 3. Developing a Web Site | 8. HTML Forms |
| 4. Design with CSS | 9. Multimedia |
| 5. Midterm | 10.Term Project |
Table of Contents
Tables are constructed using multiple elements (which means multiple tags). A table with two rows and three columns would be written in HTML like this:
<table> <tr> <!-- tr = table row, this is the beginning of a row --> <td>row 1, column 1</td> <!-- td = table data, this is a cell --> <td>row 1, column 2</td> <td>row 1, column 3</td> </tr> <tr> <td>row 2, column 1</td> <td>row 2, column 2</td> <td>row 2, column 3</td> </tr></table>
The table will be rendered in a browser like this:
| row1, column 1 | row1, column 2 | row 1, column 3 |
| row2, column 1 | row2, column 2 | row 2, column 3 |
Borders can be added using CSS. For example:
table, td { border: solid; border-collapse: collapse;}
The table will be rendered like this:
| row1, column 1 | row1, column 2 | row 1, column 3 |
| row2, column 1 | row2, column 2 | row 2, column 3 |
A special type of table cell is a heading,
<tr> <th>column 1</th> <th>column 2</th> <th>column 3</th></tr>
The table will be rendered like this:
| column 1 | column 2 | column 3 |
|---|---|---|
| row 1, column 1 | row 1, column 2 | row 1, column 3 |
| row 2, column 1 | row 2, column 2 | row 2, column 3 |
The rowspan attribute is used to make a <td> element stretch across two rows.
The colspan attribute is used to make a <td> element stretch across two columns.
<tr> <td colspan="2">row 1, columns 1 and 2</td> <td rowspan="2">rows 1 and 2, column 3</td></tr><tr> <td>row 2, column 1</td> <td>row 2, column 2</td></tr>The table will be rendered like this:
| row 1, columns 1 and 2 | rows 1 and 2, column 3 | |
| row2, column 1 | row2, column 2 | |
<caption>Table Example</caption>Captions can be positioned using CSS. For example:
caption { caption-side:bottom;}
ASP.NET Core MVC Lecture Notes by Brian Bird is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.