Be able to insert a table including table header, table rows, table data

Resources | Subject Notes | Information Communication Technology ICT

21 Website Authoring: Inserting Tables

Objective

Be able to insert a table including table header, table rows, table data.

Creating a Table

To create a table in HTML, we use the

tag. This tag acts as the container for all the table elements.

Table Structure

A table is structured into different parts:

: Contains the table header row.
  • : Contains the main body of the table, including the data rows.
  • : Represents a table row.
  • ).
  • ).

    Example Table

    Here's an example of how to insert a table with a header row, data rows, and data cells:

    Suggested diagram: A simple table with a header row and data rows.
    : Represents a table header cell (used within
    : Represents a table data cell (used within
    Name Age City
    John Doe 30 New York
    Jane Smith 25 London
    Peter Jones 40 Paris

    Explanation of the Code

    The code above defines a table with three columns: \"Name\", \"Age\", and \"City\". The section defines the header row, and the section contains the data rows with corresponding data in the cells.

    Key Tags

    • : Defines the HTML table.
    • : Defines the table header.
    • : Defines the table body.
    • : Defines a table row.
    • : Defines a table header cell.
    • : Defines a table data cell.

      Inserting a Table in a Web Page

      To insert this table into a web page, you would include the above HTML code within the section of your HTML document.

      Further Considerations

      You can customize tables further using attributes like border to add borders, colspan to merge cells horizontally, and rowspan to merge cells vertically. These are beyond the basic objective but are useful for more complex table layouts.