html
  1. html-tables

HTML Tables

HTML tables are used to display data in rows and columns on a web page.

Tables can be used to organize and present data in a clear and easy-to-read format.

How to Create Tables in HTML

Here is an example of how to create a simple table in HTML:

<table>
  <tr>
    <th>Column 1</th>
    <th>Column 2</th>
  </tr>
  <tr>
    <td>Row 1, Column 1</td>
    <td>Row 1, Column 2</td>
  </tr>
  <tr>
    <td>Row 2, Column 1</td>
    <td>Row 2, Column 2</td>
  </tr>
</table>
Try Playground

Table Formatting

HTML tables can be formatted using CSS to change the font, color, and alignment of the table and its contents. Here is an example of how to format a table using CSS:

table {
  border-collapse: collapse;
  width: 100%;
}

th, td {
  border: 1px solid #ddd;
  padding: 8px;
  text-align: left;
}

tr {
  background-color: #0891b2;
  color: #ffffff;
}
Try Playground

Importance of Tables

  • Tables can be used to organize and present data in a clear and easy-to-read format.
  • Tables can be used to compare data and highlight trends.
  • Search engines use tables to index the structure and content of web pages.
Published on: