Curriculum
Course: HTML Basic
Login

Curriculum

HTML Basic

HTML Introduction

0/1

HTML Editors

0/1

HTML Elements

0/1

HTML Attributes

0/1

HTML Headings

0/1

HTML Paragraphs

0/1

HTML Styles

0/1

HTML Formatting

0/1

HTML Quotation

0/1

HTML Comments

0/1

HTML Colors

0/1

HTML Favicon

0/1

HTML Page Title

0/1

HTML Block and Inline

0/1

HTML Iframes

0/1

HTML Java Script

0/1

HTML File Paths

0/1

HTML - The Head Element

0/1

HTML Style Guide

0/1

HTML Entities

0/1

HTML Symbols

0/1
Text lesson

HTML Tables

HTML tables enable web developers to organize data in rows and columns.

Example

Company

Contact

Country

Alfreds Futterkiste

Maria Anders

Germany

Centro comercial Moctezuma

Francisco Chang

Mexico

Ernst Handel

Roland Mendel

Austria

Island Trading

Helen Bennett

UK

Laughing Bacchus Winecellars

Yoshi Tannamuri

Canada

Magazzini Alimentari Riuniti

Giovanni Rovelli

Italy

 

Click to Learn

 

Define an HTML Table

In HTML, a table comprises cells arranged within rows and columns.

Example

A simple HTML table:

<table>
  <tr>
    <th>Company</th>
    <th>Contact</th>
    <th>Country</th>
  </tr>
  <tr>
    <td>Alfreds Futterkiste</td>
    <td>Maria Anders</td>
    <td>Germany</td>
  </tr>
  <tr>
    <td>Centro comercial Moctezuma</td>
    <td>Francisco Chang</td>
    <td>Mexico</td>
  </tr>
</table>

Table Cells

Every table cell is delineated by an opening <td> tag and a closing </td> tag.

“td” represents table data.

The content enclosed between <td> and </td> comprises the contents of the table cell.

Example

<table>
  <tr>
    <td>Emil</td>
    <td>Tobias</td>
    <td>Linus</td>
  </tr>
</table>
Note: A table cell has the flexibility to encompass various HTML elements, including text, images, lists, links, other tables, and more.

Table Rows

Every table row begins with an opening <tr> tag and concludes with a closing </tr> tag.

tr represents table row.

Example

<table>
  <tr>
    <td>Emil</td>
    <td>Tobias</td>
    <td>Linus</td>
  </tr>
  <tr>
    <td>16</td>
    <td>14</td>
    <td>10</td>
  </tr>
</table>

You can include any number of rows in a table; however, ensure that each row contains an equal number of cells.

Note: Occasionally, a row may contain a different number of cells compared to others. Further details on this topic will be covered in a subsequent chapter.

Table Headers

Occasionally, you may desire certain cells to serve as table header cells. In such instances, utilize the <th> tag instead of the <td> tag.

th” represents table header.

Example

Designate the initial row as containing table header cells.

<table>
  <tr>
    <th>Person 1</th>
    <th>Person 2</th>
    <th>Person 3</th>
  </tr>
  <tr>
    <td>Emil</td>
    <td>Tobias</td>
    <td>Linus</td>
  </tr>
  <tr>
    <td>16</td>
    <td>14</td>
    <td>10</td>
  </tr>
</table>

By default, the text within <th> elements is bold and centered; however, you can modify this appearance using CSS.