×
   ❮     
HTML CSS MySql Javascript SQL PYTHON JAVA C++ C# BOOTSTRAP REACT XML NODEJS ANGULAR DJango Rust Android VUE
     ❯   

HTML Table


What is Table in HTML?

HTML tables allow web developers to arrange data into rows and columns.

Table consists of table cells inside rows and columns.


HTML Table Concepts:

Note: Each table cell is defined by a <td> and a </td> tag.

td stands for table data.

Note: Each table rows is defined by a <tr> and a </tr> tag.

tr stands for table rows.


Note: In those cases use the <th> tag instead of the <td> tag.

th stands for table header.

HTML Table Header

Example of HTML Table Header <th>Header:</th>

Example

<table>
  <tr>
    <th>Name</th>
    <th>Year</th>
  </tr>
  <tr>
    <td>C++</td>
    <td>2000</td>
  </tr>
</table>
Try it Yourself »

HTML Table with one rows

Table with one row <tr>Table row</tr>

Example

<table>
  <tr>
    <th>Name</th>
    <th>Year</th>
  </tr>
</table>
Try it Yourself »

Example of HTML Table with more than one rows

Full html code with table with more than one rows and it contain css code.

Example

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Programming Languages Table</title>
  <style>
    table {
      width: 50%;
      border-collapse: collapse;
      margin: auto;
      margin-top: 20px;
    }
    th, td {
      padding: 12px;
      border: 1px solid #3498db;
    }
    th {
      background-color: #3498db;
      color: #ffffff;
    }
    tr:nth-child(even) {
      background-color: #f2f2f2;
    }
  </style>
</head>
<body>
  <table>
    <tr>
      <th>Name</th>
      <th>Year</th>
    </tr>
    <tr>
      <td>C++</td>
      <td>2000</td>
    </tr>
    <tr>
      <td>Java</td>
      <td>2005</td>
    </tr>
  </table>
</body>
</html>
Try it Yourself »

Hey there! Let's go for Learn fasta then! It is more than just coding; it is to have the superpower that can solve any problem. Through simple and easy-to-grasp examples you will sail through the learning process. In addition, it is not just about coding– you will acquire competencies on how to solve complex problems, analyze data, and come up with efficient solutions. Shall we start this wonderful journey together! learnfasta.com terms of use, Copyright 2025 All Rights Reserved.