COLSPAN and ROWSPAN

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.

Answer:

Of course.

COLSPAN and ROWSPAN

Saxons
Monarch Reign
Edward the Confessor 1042-1066
Harold II 1066
House of Normandy
Monarch Reign
William I 1066-1087
William II 1087-1100
Henry I 1100-1135
Stephen 1135-1154

Sometimes a table has a heading cell that spans the distance of several data cells, such as the table at the right. A cell can be made to span two columns by putting the the attribute colspan="2" inside a <th> tag (or a <td> tag). For example, the "Saxons" row of the table was done like this:

<tr> <th colspan="2" align="center">Saxons</th> </tr>

This also illustrates that you can align the individual elements within their cells with an align attribute.

It is also possible to tell a cell to span two or more rows using the rowspan="" attribute. And, and individual cell can span multiple rows and multiple columns by including both the colspan and the rowspan attribue.

There are many other interesting things you can do with tables. For example, you can have a complete table as a data item for a cell of an outer table.


QUESTION 14:

Could an image fill a table cell?