Tables

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.
go to previous page   go to home page   go to next page        

Answer:

No — talking about how many pixels of space to use is not at all a functional description.

Tables

The latest Web standards make a clean split between function and format. You are supposed to use XHTML for functional descriptions (only) of Web page elements and to use Cascading Style Sheets for stylistic (fomatting) descriptions. But this idea is weakly and unevenly supported so for now try to use HTML formatting sparingly.

Here is a simple table:

William I 1066-1087
William II 1087-1100
Henry I 1100-1135
Stephen 1135-1154

It is created with the following HTML:

<table border="1">
<tr> <td>William I </td>  <td>1066-1087</td> </tr>
<tr> <td>William II</td>  <td>1087-1100</td> </tr>
<tr> <td>Henry I   </td>  <td>1100-1135</td> </tr>
<tr> <td>Stephen   </td>  <td>1135-1154</td> </tr>
</table>

A table has one or more rows. Each row contains one or more table data items or table heading items. Usually there is an equal number of items in each row (there are ways around this limitation.)

  1. A table is bracketed with the tags <table> and </table>.
  2. If you want lines to separate the cells of the table, use border="1" to ask for a border thinkness of one.
    • Use larger values for thicker borders.
    • A thinkness of 0 results in no borders.
  3. The table rows are put between the table tags
  4. Each row is bracketed with the tags <tr> and </tr>.
  5. Between the <tr> tags are one or more table data items.
  6. Each item of table data is bracketed with the tags <td> and </td>.
  7. Between the table data tags is where you put the text you wish to display.
  8. Each table heading item is bracketed with the tags <th> and </th>.

QUESTION 5:

Will the following HTML correctly produce the above table?

<table border="border">

    <tr> 
        <td>William I</td>  
        <td>1066-1087</td> 
    </tr>

    <tr> 
        <td>William II</td>  
        <td>1087-1100</td> 
    </tr>

    <tr> 
        <td>Henry I   </td>  
        <td>1100-1135</td> 
    </tr>

    <tr> 
        <td>Stephen   </td>  
        <td>1135-1154</td> 
    </tr>

</table>