Table Data Attributes

line.gif

Column and Row Spanning

The attributes colspan and rowspan of the tag <td> allow for the specification of complex tables. An example of column spanning is shown below.

<table cellpadding=5 border=2 width=20%>
<tr align=center> <td colspan=3> <b>Alphabet</b>
<tr align=center> <td> A <td> B <td> C
<tr align=center> <td> D <td> E <td> F
</table>

The above code produces the following result.

Alphabet
A B C
D E F

Likewise, rows may also be spanned, as shown below.

<table cellpadding=5 border=2 width=20%>
<tr align=center> <td rowspan=2> <b>Alphabet</b> <td> A <td> B <td> C
<tr align=center> <td> D <td> E <td> F
</table>

which produces the table below.

Alphabet A B C
D E F

Other Table Data Attributes

When applied to a single cell, the attributes

have the same meaning as for the tag <tr>. Any attribute applied to a cell overrides the same attribute applied to a row, which in turn overrides the same attribute applied to the entire table.

The cell attribute nowrap may be useful on occasion to prevent word wrap on particular items within a table.

Other Table Tags

Other tags relating to tables include:

Exercise 16

The following table uses superscripts, subscripts, captions and column spanning (discussed above) to produce the result.
25510 in Hex and Binary
16n 161 160
Hex f f
2n 27 26 25 24 23 22 21 20
Binary 1 1 1 1 1 1 1 1

Write a HTML document that:

Take this link to see the solution of the exercise. You should view the source of the solution and compare it to that which you provided. You should add the solution of this exercise to the samples panel that you created in exercise 6. The next chapter next.gif discusses frames, yet another useful device of HTML.