top of page
HTML5.png

HTML

TABLE TAG

  • HTML allows us to enter the data in tabular form in a webpage.

  • It includes <TABLE>, <TR>, <TD>, <TH>, <CAPTION>, <THEAD>, <TFOOT>, etc.

  • A table is a collection of records or rows.

  • The intersection point of row and column is called “cell”.

  • Table tags:​​

​

table.JPG

Colspan:

  • This is an attribute of <TABLE> tag which is used to combine two or more columns and display them as a single column.

  • Syntax:

<th colspan=”value”> or <td colspan=”value”>

  • Example:

<th colspan=”2”>

Rowspan:

  • This is an attribute of <table> tag which is used to combine two or more rows and display them as a single row.

  • Syntax:

<th rowspan=”value”> or <td rowspan=”value”>

  • Example:

<th rowspan=”2”>

Cellpadding:

  • This is an attribute of <table> tag which is used to represent the distance between the cell border and content within a cell.

Cellspacing:​

  • This is an attribute of <table> tag which is used to represent the width of the border of a table.

Table bgcolor:

  • This attribute is used to change the background color of the table.

Border color:​

  • This attribute is used to change the border color of the table.

​

Example:

<html>

<head>

<title> TABLE </title>

</head>

<body>

<table border="1">

<caption> EMPLOYEE </caption>

​<tr>

<th colspan=”2”> NAME </th>

<th rowspan=”2”> SALARY </th>

​</tr>

​<tr>

<th> FIRST_NAME </th>

<th> LAST_NAME </th>

​</tr>

​<tr>

<td> SHREYASH </td>

<td> PRADHAN </td>

<td> 50000 </td>

​</tr>

​<tr>

<td> HAPPY </td>

<td> SINGH </td>

<td> 48000 </td>

</tr>

​<tr>

<td> RAKESH </td>

<td> ROSHAN </td>

<td> 46000 </td>

</tr>

​<tr>

<td> ROHAN </td>

<td> PRADHAN </td>

<td> 98000 </td>

</tr>

</table>

</body>

</html>

​

OUTPUT:

​

tab.JPG

Related Topics

bottom of page