HTML Tags

HTML <table> Tag

The <table> tag in HTML defines a table — a structured arrangement of data in rows and columns.
It serves as the container for all related elements like <tr>, <th>, <td>, <thead>, <tbody>, and <tfoot>

Syntax

<table>
  <tr>
    <th>Heading 1</th>
    <th>Heading 2</th>
  </tr>
  <tr>
    <td>Data 1</td>
    <td>Data 2</td>
  </tr>
</table>

Attributes

AttributeDescription
borderSpecifies the border width around table cells (deprecated, use CSS).
cellpaddingSpace between cell content and its border (deprecated, use CSS).
cellspacingSpace between cells (deprecated, use CSS).
widthSets the table’s width (deprecated, use CSS).
summaryProvides a summary of the table’s purpose (deprecated, use <caption> instead).

Example

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Table Tag Example</title>
  <style>
    table {
      width: 60%;
      border-collapse: collapse;
      margin: 20px auto;
    }
    th, td {
      border: 1px solid #555;
      padding: 10px;
      text-align: center;
    }
    th {
      background-color: #29AB87;
      color: white;
    }
  </style>
</head>
<body>

  <h2>HTML Table Example</h2>

  <table>
    <tr>
      <th>Language</th>
      <th>Type</th>
      <th>Year Introduced</th>
    </tr>
    <tr>
      <td>HTML</td>
      <td>Markup</td>
      <td>1993</td>
    </tr>
    <tr>
      <td>CSS</td>
      <td>Style Sheet</td>
      <td>1996</td>
    </tr>
    <tr>
      <td>JavaScript</td>
      <td>Programming</td>
      <td>1995</td>
    </tr>
  </table>

</body>
</html>

Output

Browser Output

Displays a well-formatted table with 3 columns and 3 rows, styled using CSS.
Please use our TryIt editor to see the actual rendering.

Browser Support

Chrome
Chrome
Firefox
Firefox
Edge
Edge
Safari
Safari
Opera
Opera
IE
IE9+
✅Yes✅Yes✅Yes✅Yes✅Yes✅Yes

All major browsers fully support the <table> element.

Notes

  • The <table> element is the parent container for all table-related elements.
  • Use <thead>, <tbody>, and <tfoot> for semantic grouping.
  • CSS should be preferred for styling (borders, spacing, alignment).
  • For accessibility, include a <caption> or use scope attributes in header cells.

Conclusion

The <table> tag is the backbone of tabular data in HTML.
When combined with semantic child elements and proper CSS, it allows for both well-structured and visually appealing data presentation.

Sign In Form

User your email and password to singn in

Provide your email and we will send you a password reset link.

Don’t have an account, signup here : 

HTML5 & CSS3

Tools and Tutorials

Want a Website

Want a website for your business ?

Please fill out the details below, so we can reach out to you.

Registration Form

Signup to track your record and much more.

We have sent you an email with a registration link. Please click the link to verify your email address, or enter the 6-digit OTP provided in the email.

Didn't receive the OTP. Regenerate OTP Resend