125 words
1 minutes
Creating Tables in HTML: A Guide

Creating Tables in HTML: A Guide#

Tables in HTML are used to display tabular data. This guide provides an overview of creating tables in HTML.

Basic Syntax#

The basic structure of an HTML table includes the <table>, <tr>, <th>, and <td> elements:

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

Adding a Caption#

You can add a caption to a table using the <caption> element:

<table>
  <caption>Table Caption</caption>
  <!-- Table rows and cells -->
</table>

Spanning Rows and Columns#

Use the rowspan and colspan attributes to span rows and columns:

<table>
  <tr>
    <th rowspan="2">Header 1</th>
    <th>Header 2</th>
  </tr>
  <tr>
    <td>Data 2</td>
  </tr>
</table>

Conclusion#

Creating tables in HTML is straightforward with the use of table elements and attributes. By following this guide, you can effectively display tabular data on your webpages.


Creating Tables in HTML: A Guide
https://zxce3.net/posts/html/creating-tables-in-html-a-guide/
Author
Memet Zx
Published at
2021-08-08