Table Tags in HTML
- A table is a matrix of rows and columns. The HTML table provides a highly readable way of presenting many kinds of information.i.e by using table we can present information in structuring format.
- HTML tables are used to manage the layout of the page e.g. header section, navigation bar, body content, footer section etc. but it is recommended to use div tag over table to manage the layout of the page.
The basic table tags:
<table>------</table>
It indicates the starting of the table.The most common attribute for <table> tag is border,And it has different attributes like height,width....,
<th>------</th>
It is used to give table heading(column header).
<tr>-------</tr>
It is used to start a table row.
<td>------</td>
It indicates a table data or a cell.
<caption>------</caption>
It is used to insert caption into table.
format :
Commonly used arguments in table
- align: It specifies alignment of table.i.e, left or center or right.
- border: It specifies border of table in pixels.
- height: It sets amount of screen that table will use in the factor of height.
- width: It sets amount of screen that table will use in the factor of width.
- cellpadding: It specifies the space between content of cell and its border.
- cellspacing: It specifies the space between content of cells.
- colspan: It is used combine two or more columns.
- rowspan: It is used to combine two or more rows.
Example : "
table.html"
Table
Employee Details
EID |
ENAME |
AGE |
101 |
Madhu |
32 |
102 |
Naveen |
33 |
Output:
☑ HTML Table with colspan :
If you want to combine more than one column, you can use the colspan attribute.
Let's see the example that span or combine two columns
Example : "
tablecols.html"
Table-Colspan
Name |
Mobile No. |
B.Tech-CSE |
1234567890 |
9876543210 |
Output:
☑ HTML Table with rowspan :
If you want to combine more than one row, you can use the rowspan attribute.
Let's see the example that span or combine two rows.
Example : "
tablerows.html"
Table-Rowspan
Name |
B.Tech-CSE |
Mobile No. |
1234567890 |
9876543210 |
Output:
Next Topic :Image Tag in HTML