HTML and CSS Reference
The following example creates a simple table that shows the results achieved by three students on their math exam.
The border attribute on the <table> tag adds a 1-pixel border to the table so that we can see the rows and
columns clearly. The first row contains two <th> elements that make up the column headings; browsers will usually
display these in bold text by default. We then define the records by creating three separate rows, each containing two
<td> elements (table cells), one for the pupil's name and the one for his or her exam result. Figure 4-8 shows this
table displayed in a browser.
Figure 4-8 A table of exam results.
Table Cell Attributes
Both <td> and <th> elements have a number of attributes that can be used to help format them. One example is
the colspan (column span) attribute. Use the colspan attribute in instances where you need a particular table
cell to span multiple columns. The following example uses the colspan attribute to create a cell that spans the
<th colspan="2">Class 2B</th>