HTML Tutorial 11
Prepared by: Anthony Larrain
Tables
- HTML tables allow you to arrange text and graphics into multiple rows and columns.
- Tags used in creating tables.
- The
<table>
</table>
tags define the beginning and end of a table. - The
<tr> </tr>
tags define the rows of the table. - The
<td> </td>
tags creates the data cells. - The actual content is placed within the
td
tags. - A data cell can contain text, images, lists, paragraphs, horizontal rules, tables, etc.
Example 1
The following piece of code:
Data Cell One | Data Cell Two |
Data Cell Three | Data Cell Four |
- Produces this page table1.html
- The size of a table and its cells automatically adjust to fit the data.
- You can control the size of a table using the
width
attribute.
Example 2
Column1 | Column2 |
---|---|
Data Cell One | Data Cell Two |
Data Cell Three | Data Cell Four |
- See table6.html
- Notice the headings are centered horizontally, and the data in the data cells are left justified.
- You can control the alignment of the heading and data within each table cell by using the
align
attribute. - Values to the
align
attribute are,left, center, right
- See table7.html. Don't forget to view the source.
Design Tip
- Use CSS to align headings and data
- See table8.html. Don't forget to view the source.