HTML
Hypertext Markup Language
The HTML code that follows creates tables that are somewhat more complicated.
By adding the Rowspan and Colspan attribute to the table elements, it is possible to create data cells that span a given number of rows or columns.
Attribute | Description |
---|---|
ROWSPAN | This Rowspan attribute to more than the number of rows in the table does not extend the size of the table. |
COLSPAN | This is used to create table cells (<td>) that contain headlines and subheaders that run across the width of the entire table. |
HTML Code
<html>
<head>
<title>table</title>
</head>
<body>
<table border="1" width="400" height="300">
<caption> Basic Fruit Comparison Chart </caption>
<tr>
<th width="200" align="center">Fruit</th> <th width="200" align="center">Color</th> </tr>
<tr>
<td align="center" colspan="2" >Apple</td> </tr>
<tr>
<td align="center">Avocado</td> <td align="center" rowspan="2" >Green</td> </tr>
<tr>
<td align="center">Watermelon</td> </tr>
</table> </body>
</html>
<head>
<title>table</title>
</head>
<body>
<table border="1" width="400" height="300">
<caption> Basic Fruit Comparison Chart </caption>
<tr>
<th width="200" align="center">Fruit</th> <th width="200" align="center">Color</th> </tr>
<tr>
<td align="center" colspan="2" >Apple</td> </tr>
<tr>
<td align="center">Avocado</td> <td align="center" rowspan="2" >Green</td> </tr>
<tr>
<td align="center">Watermelon</td> </tr>
</table> </body>
</html>
Output
Fruit | Color |
---|---|
Apple | |
Avocado | Green |
Watermelon |