HTML table attributes are used to define various properties and behaviors of tables on a web page. Here are some common HTML table attributes:
1. ‘border’ Attribute:
Specifies the width of the border around the table or individual cells. For example, border=”1″ will display a border around the table cells.
Syntax:
<table border="1">
<!-- table content goes here -->
</table>
2. ‘width‘ and ‘height’ Attribute:
Defines the width and height of the table, respectively. You can specify these values in pixels or as a percentage of the available space.
Syntax:
<table width="100%" height="200">
<!-- table content goes here -->
</table>
3. ‘cellpadding‘ and ‘cellspacing’ Attribute:
Syntax:
<table cellpadding="10" cellspacing="5">
<!-- table content goes here -->
</table>
4. ‘align’ Attribute:
Aligns the table on the page horizontally. Possible values include “left”, “center”, and “right”.
Syntax:
<table align="center">
<!-- table content goes here -->
</table>
4. ‘colspan’ and ‘rowspan’ Attribute:
colspan is used to span multiple columns within a table row, and rowspan is used to span multiple rows within a table column.
Syntax:
<td colspan="2">This cell spans two columns</td>
<td rowspan="3">This cell spans three rows</td>
There are some of the commonly used attributes for HTML tables. Each attribute helps define the structure, appearance, and behavior of tables on a web page.