Table attribute - HTML
Attribute list needs to create a table are given below :
1. width
2. height
3. border
4. rowspan
5. collspan
we saw the border effect in previous Part.
Example :
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Table</title>
</head>
<body>
<table border="1" width="300" height="250">
<tr>
<td>Row 1 Col 1</td>
<td>Row 1 Col 2</td>
<td>Row 1 Col 3</td>
</tr>
<tr>
<td>Row 2 col 1</td>
<td>Row 2 col 2</td>
<td>Row 2 col 3</td>
</tr>
<tr>
<td>Row 3 col 1</td>
<td>Row 3 col 2</td>
<td>Row 3 col 3</td>
</tr>
</table>
</body>
</html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Table</title>
</head>
<body>
<table border="1" width="300" height="250">
<tr>
<td>Row 1 Col 1</td>
<td>Row 1 Col 2</td>
<td>Row 1 Col 3</td>
</tr>
<tr>
<td>Row 2 col 1</td>
<td>Row 2 col 2</td>
<td>Row 2 col 3</td>
</tr>
<tr>
<td>Row 3 col 1</td>
<td>Row 3 col 2</td>
<td>Row 3 col 3</td>
</tr>
</table>
</body>
</html>
Output:
<caption> tag used for making a heading of a table and <caption> write next to the <table> (opening tag) tag like:
<table>
<caption>Heading</caption>
<tr>
<td>Row 1 Col 1</td>
</tr>
<tr>
<td>Row 1 Col 1</td>
</tr>
</table>
If we use the <caption> tag in the code is given above, then the output is :
No comments:
Post a Comment