HTML Tables
Tables are used to display data in a tabular format. Learn how to create tables in HTML and style them using CSS.
It allows you to arrange data like text, images, and links in rows and columns. You use the <table> tag to start and end a tab
Syntax of HTML Table
Here is the basic syntax of an HTML table:
<table>
<!-- Table content -->
</table>Key Elements of HTML Table
<table>: Defines the table itself.<tr>: Used for table rows.<th>: Used for table headings.<td>: Used for table cells (data).
Basic Table Structure
Here is a simple example of an HTML table:
<table>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td>Shyam</td>
<td>26</td>
</tr>
</table>rowspan and colspan Attributes
Rowspan: If you want a table cell to span multiple rows, you can use the rowspan attribute.
<td rowspan="value">```</td>Colspan: If you want a table cell to span multiple columns, you can use the colspan attribute.
<td colspan="value">```</td>Visual Representation of Rowspan and Colspan

Examples
Here are simple examples to demonstrate the use of rowspan and colspan in HTML tables.
Example for Colspan
<table border="1">
<tr>
<td colspan="2">Merged Columns</td>
</tr>
<tr>
<td>Column 1</td>
<td>Column 2</td>
</tr>
</table>Example for Rowspan
<table border="1">
<tr>
<td>Row 1, Column 1</td>
<td rowspan="2">Merged Rows</td>
</tr>
<tr>
<td>Row 2, Column 1</td>
</tr>
</table>Conclusion
Tables are a great way to display data in a structured format. You can use the <table>, <tr>, <th>, and <td> tags to create tables in HTML. You can also use the rowspan and colspan attributes to merge cells in a table. Tables can be styled using CSS to make them visually appealing.
How is this guide?
Sign in to share your feedback
Help us improve by sharing your thoughts on this guide.
Last updated on