KCLCCHMinor programmeAV1000Electronic communications and publishing


AV1000
Fundamentals of the digital humanities
HTML Tables

  1. A basic table
  2. Elements and attributes
  3. Suggested exercise
  4. References

An HTML table has two primary uses: laying out tabular alphanumeric information and, less obviously, controlling the spatial relationships of objects on the page, especially images. Current browsers are rather poor at arranging images or images together with text when the browser window is too narrow. The table is the best means we now have of addressing that difficulty. See the page on imaging for details.

A. A basic table

The following is a typical structure of rows and columns used to arrange alphanumeric information into self-contained areas or "cells":

Building type Date Location Architect Description
Public lavatories 1897 Hampstead, South End Green ? Below ground; walls tiled in green & white, floor in black & white
Telephone kiosk 1935 Lambeth Palace Road, Albert Embankment Sir Giles Gilbert Scott Type K6; cast iron, square, with domed roof.
Terraced house 1734; early 20C alt. Dean Street, Westminster, W1 John Nolloth (?) Solid brick with red brick dressings, slate roofs, 4 stories, 3 windows wide.
Terraced house 1692; 19C alt. Dean Street, Westminster, W1 ? Stock brick, slate roof, 4 stories, 3 windows wide. Ground floor has 20C restaurant.
Hotel 1851 Great Northern Hotel, Pancras Road Lewis Cubitt Stock brick, stucco dressings, slate roof. Crescent-shaped. 5 stories plus attic and basement.

The HTML that produces the above table looks like this (leaving out some of the later rows):

  <table border="5" cellpadding="5">
    <tr>
      <th> Building type </th>
      <th> Date </th>
      <th> Location </th>
      <th> Architect </th>
      <th> Description </th>
    </tr>
    <tr>
      <td> Public lavatories </td>
      <td> 1897 </td>
      <td> Hampstead, South End Green </td>
      <td> ? </td>
      <td> Below ground; walls tiled in green &amp; white, floor in black &amp; white </td>
    </tr>
    <tr>
      <td> Telephone kiosk </td>
      <td> 1935 </td>
      <td> Lambeth Palace Road, Albert Embankment </td>
      <td> Sir Giles Gilbert Scott </td>
      <td> Type K6; cast iron, square, with domed roof. </td>
    </tr>
    …
  </table>
  

Note the basic structure: the table as a whole (<table> … </table>) contains a set of rows (<tr> … </tr>), each of which contains a set of data-elements (<td> … </td>) within each of which the text for the cell is specified. (The <th> … </th> elements are a variant of the <td> … </td> used for headers.) Note the attributes in the <table> tag; these are explained below.

B. Elements and attributes

The basic elements of a table are:

Element Function Contains
<table> … </table> defines the table everything else
<tr> … </tr> (table row) defines a row the following
<th> … </th> (table header) provides label for column text only
<td> … </td> (table data) defines contents of a cell text or image

The basic attributes used in a table are:

Element Attribute Values Function
table border pixel value puts a border around the cells
  cellspacing pixel value puts space between cells
  cellpadding pixel value puts space between cell wall and data
  width pixel value or percent determines width of the whole table
  align left or right causes table to be placed left or right, with text flowing around
  valign top or bottom aligns text in cells at the top or bottom of the cell
tr align left, center, right see above
  valign top, middle, bottom see above
td / th align left, center, right see above
  valign top, middle, bottom see above
  colspan nr of columns specifies how many columns cell should span
  rowspan nr of rows specifies how many rows cell should span

C. Suggested exercise

Create a new Web page consisting of a table for the major pollutants affecting life and buildings in major urban centres such as London. The columns should be labelled with the following headers:

Use the following data. Condense and abbreviate wherever possible without obscuring any of the relevant facts—i.e. try to produce a visually compact table.

  1. Sulphur dioxide (SO2), corrosive acid gas which combines with water vapour in the atmosphere to produce acid rain. Implicated in the damage and destruction of vegetation and in the degradation of soils, building materials and watercourses. SO2 in ambient air is also associated with asthma and chronic bronchitis. Principal source of this gas is power stations burning fossil fuels which contain sulphur.
  2. Particulates (PM10), air-borne particulates of very small size (<10 μm); vary widely in its physical and chemical composition, source and particle size. Smallest can penetrate deep into the lungs and so potentially pose significant health risks, including increased risk of heart and lung disease; they may carry surface-absorbed carcinogenic compounds into the lungs. Principal source in European cities is road traffic emissions, particularly from diesel vehicles.
  3. Carbon monoxide (CO), a toxic gas which is emitted into the atmosphere as a result of combustion processes, and is also formed by the oxidation of hydrocarbons and other organic compounds. At levels found in ambient air may reduce the oxygen-carrying capacity of the blood. In European urban areas produced almost entirely (90%) from road traffic emissions.
  4. Nitrogen dioxide (NO2), a toxic gas, respiratory irritant (may exacerbate asthma, increase susceptibility to infections); in sunlight reacts with hydrocarbons to produce photochemical pollutants such as ozone; contributes to acid rain. Principal source is road traffic, responsible for approximately half the emissions in Europe.
  5. Ozone (O3), a secondary pollutant produced by reaction between nitrogen dioxide, hydrocarbons and sunlight. Can irritate the eyes and air passages causing breathing difficulties and may increase susceptibility to infection. It is a highly reactive chemical, capable of attacking surfaces, fabrics and rubber materials; also toxic to some crops, vegetation and trees.
  6. Volatile organic compounds (VOCs). Benzene, an aromatic VOC, minor constituent of petrol; known human carcinogen; major source is combustion by petrol-using vehicles. 1,3-butadiene, a VOC emitted into the atmosphere principally from fuel combustion of petrol and diesel vehicles; important constituent to production of synthetic rubber; a known potent human carcinogen.
  7. Toxic Organic Micropollutants (TOMPs,) produced by the incomplete combustion of fuels; comprise a complex range of highly toxic or carcinogenic chemicals. Include PolyAromatic Hydrocarbons (PAHs), PolyChlorinated Biphenyls (PCBs), Dioxins, Furans.

D. References

  1. An XHTML tables reference page
  2. HTML and CSS Table Border Style Wizard by Shailesh N. Humbad, helpful for learning about how to manage the different border properties

revised October 2007