Tables in HTML

  • Last updated Apr 25, 2024

In HTML, tables are structural elements used to display data in a tabular format, organizing information into rows and columns.

Here's the basic structure of an HTML table:

    <th>Header 1</th>
    <th>Header 2</th>
    <td>Data 1</td>
    <td>Data 2</td>
  • <table>: The container element for the entire table.
  • <tr>: Stands for table row and contains the cells (data or header) of a row.
  • <th>: Represents a header cell, typically used for column and row headings.
  • <td>: Represents a data cell, holding the actual content.

Here's an example of a simple HTML table:

Name Registration Number Programming course
Mikke 10005 Java
Danny 10004 Python
Kenny 10003 .Net
Victory 10002 PHP
Jimmz 10001 React

Complete code for creating a table in an HTML document:

<!doctype html>
<html lang="en">
<title>My web page</title>
     td {
          border:1px solid black;
<table class="table table-sm table-bordered">
        <th>Registration Number</th>
        <th>Programming course</th>