0% found this document useful (0 votes)
6 views4 pages

HTML Table Structure and Attributes

HTML tables are used to present data in rows and columns, utilizing elements like <table>, <tr>, <th>, <td>, and <caption>. The rowspan and colspan attributes allow cells to span multiple rows or columns, respectively. Examples illustrate the structure and usage of these elements and attributes in creating tables.

Uploaded by

karthik m
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views4 pages

HTML Table Structure and Attributes

HTML tables are used to present data in rows and columns, utilizing elements like <table>, <tr>, <th>, <td>, and <caption>. The rowspan and colspan attributes allow cells to span multiple rows or columns, respectively. Examples illustrate the structure and usage of these elements and attributes in creating tables.

Uploaded by

karthik m
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

HTML Tables

HTML tables are used to display data in a structured


tabular format using rows and columns.
table elements
 <table>: The container element that defines the
start and end of a table.
 <tr>: Stands for "table row". Each <tr> tag defines
a row in the table.
 <th>: Stands for "table header". It's used for the
headers of the columns
 <td>: Stands for "table data". This tag is used for
actual data cells under each column.
 <caption>: Provides a descriptive title for the table.
This should be the first element after the opening
<table> tag.

Ex
<table border="1">
<tr>
<th>Heading 1</th>
<th>Heading 2</th>
</tr>
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
</tr>
<tr>
<td>Cell 4</td>
<td>Cell 5</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">
Colspan: If you want a table cell to span multiple columns, you
can use the colspan attribute.
<td colspan="value">

EX (Colspan)

<table border="1">
<tr>
<th colspan="2">Name</th>
<th>Age</th>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
<td>30</td>
</tr>
<tr>
<td>Jane</td>
<td>Smith</td>
<td>25</td>
</tr>
</table>
EX (Rowspan)

<table border="1">
<tr>
<th rowspan="2">Name</th>
<th>Subject</th>
<th>Score</th>
</tr>
<tr>
<th>Subject</th>
<th>Score</th>
</tr>
<tr>
<td rowspan="2">John</td>
<td>Math</td>
<td>85</td>
</tr>
<tr>
<td>Science</td>
<td>90</td>
</tr>
</table>

You might also like