Tables are an essential component of HTML, allowing us to present data in an organized and readable format. In this article, we will guide you through displaying tables in HTML and provide practical examples. If you've ever wondered how to create and structure tables in your web pages, this will serve as an comprehensive guide.

Tables in HTML are primarily used for tabular data that needs to be presented in a grid format. They can be used to display data in a structured manner, making it easier for users to understand and navigate. So, let's dive into the details of how to create and display tables in HTML.

Creating a Basic HTML Table
Every table in HTML begins with the <table> tag and ends with the </table> tag. Within these tags, you add the rows of your table using the <tr> tag, with each cell of your table defined by the <td> tag. The header of your table is defined by the <th> tag.

Here's a simple example of a basic HTML table:
<table>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
</tr>
</table>
Table Rows and Cells

The <tr> and <td> tags are used to create the rows and cells of the table, respectively. In the above example, the first <tr> creates a row within the table and the <th> tags within it define the table headers. The second <tr> creates another row and the <td> tags within it define the data cells.
The number of <th> and <td> tags within each <tr> should match. The first row typically contains headers, and subsequent rows contain the data.
Spanning Cells

Sometimes you may want a header or data cell to span multiple columns or rows. This can be achieved using the colspan or rowspan attributes within the <th> or <td> tags. For example:
<table>
<tr>
<th>Header 1</th>
<th colspan="2">Header 2</th>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
</tr>
</table>
Styling Tables in HTML
HTML tables can be styled using CSS. You can apply styles to the entire table, specific rows or cells, or even specific cells within a row. By using CSS, we can control the appearance of the table, including colors, font sizes, borders, and more. In the following example, we've added some basic CSS to our table:

<style>
table {
border-collapse: collapse;
width: 50%;
}
th, td {
border: 1px solid black;
padding: 8px;
text-align: left;
}
</style>
<table>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
</tr>
</table>
This is a simple introduction to creating and styling tables in HTML. HTML tables provide a powerful way to present complex data in a user-friendly manner. They can be used in a variety of situations, from displaying information to creating interactive forms. As you become more familiar with HTML and CSS, you can create more complex and visually appealing tables for your websites.
Remember, the key to effective use of tables is organizing your data in a way that makes sense and using appropriate headers to guide your users. Happy coding, and we hope this guide has given you a strong foundation for working with tables in HTML!



















