XML technologies / HTML & XHTML / Alphabetical list of HTML and XHTML elements / table

(Excerpt from "HTML & XHTML ─ kurz & gut" by Jennifer Niederst Robbins)

A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

   

table

HTML 4.01 | HTML 5

<table> ... </table>

Marks a table displaying rows and columns of data or other information. The minimum elements needed to define a table are: table, to create the table itself, tr for a table row and td, to define individual cells within a column. The complete table model appears below.

Start/end tag

Required/required

Attributes

Core, internationalization, events, global HTML 5 attributes

  • align="left|right|center"

    Deprecated. Not in HTML 5. Aligns the table within the text flow, working like align for the img element. The default alignment is left (left). The value center is not universally supported.

  • bgcolor="#rrggbb" oder "Farbname"

    Deprecated. Not in HTML 5. Defines a background color for the entire table using hexadecimal RGB values or a color name. However, colors should properly be defined with stylesheets.

  • border="Zahl"

    Not available in HTML 5. Sets the width in pixels of the outer border around the table and its cells. The value 0 (zero) disables all borders. The default is 1. Specifying the word border without a value creates a 1-pixel border. This is not valid in XHTML.

  • cellpadding="Zahl"

    Not available in HTML 5. Defines the space in pixels between a cell’s edges and its content. The default is 1.

  • cellspacing="Zahl"

    Not available in HTML 5. Defines the space in pixels between table cells. The default is 2.

  • frame="void|above|below|hsides|lhs|rhs|vsides|box|border"

    Not available in HTML 5. Tells the browser where to draw borders around the table:

    Value

    Description

    void

    No border (default)

    above

    Top only

    below

    Bottom only

    hsides

    Top and bottom only

    vsides

    Left and right only

    lhs

    Left only

    rhs

    Right only

    box

    All four sides

    border

    All four sides

    Table: Possible values of the table attribute frame

  • height="Zahl" oder "Prozentwert"

    Not standards-compliant. Defines the minimum height of the entire table in pixels or as a percentage of its parent element. Since this element is not standards-compliant, documents using it will not validate.

  • rules="all|cols|groups|none|rows"

    Not available in HTML 5. Tells the browser where to draw rules within the table. If the attribute border has a value greater than zero, rules defaults to all, unless otherwise specified. This attribute is not universally supported. Possible values are:

    Value

    Description

    all

    Rules appear between all rows and columns.

    colls

    Rules appear only between columns.

    groups

    Rules appear between row groups (thead, tfoot and tbody).

    none

    No rules (default)

    rows

    Rules appear only between rows.

    Table: Possible values of the table attribute rules

  • summary="Text"

    Contains a summary of the table’s content for nonvisual browsers. In HTML 5, authors are encouraged to use the element caption instead.

  • width="Zahl" oder "Prozentwert"

    Not available in HTML 5. Defines the entire table’s width in pixels or as a percentage of its parent element.

Examples

A simple table with two rows and two columns:

<table width="70%" cellpadding="10">
  <tr>
    <td>Zelle 1</td><td>Zelle 2</td>
  </tr>
  <tr>
    <td>Zelle 3</td><td>Zelle 4</td>
  </tr>
</table>

 

The correct order in the complete table model, shown here in HTML syntax, appears below. For details, see the entries for the elements caption, tbody, thead, tfoot, colgroup and col.

<table>
<caption>Angestelltengehälter und Eintrittsdaten</caption>
<colgroup id=" employeeinfo">
  <col span="2" width="300">
  <col span="1" width="100" class="date">
</colgroup>
<thead>
  <tr>
    <th>Angestellter</th><th>Gehalt</th><th>Eintrittsdatum</th>
  </tr>
</thead>
<tfoot>
  <tr><td colspan="3">Erstellt von Betty D. Boss</td></tr>
</tfoot>
<tbody>
  <tr>
    <td>Wilma</td><td>50.000</td><td>6. April 2010</td>
  </tr>
  <tr> ... (mehr Datenzellen) ...</tr>
  <tr> ... (mehr Datenzellen) ...</tr>
</tbody>
</table>

 

> back to the alphabetical list of elements

   

 

 

 

back to top