Optional Attributes of <td> tag :- align|Axis|charoff|valign|bgcolor|char
Thesee attributes are not valid in HTML5 but in earlier version these are valid.
You can understand use of <td> tag by a simple example:-
e.g.1
<!DOCTYPE html>
<html>
<head>
<title>use of td tag</title>
</head>
<body>
<table border="1">
<tr>
<th>Name</th> <th>month</th> <th>Income</th>
</tr>
<tr>
<td>Rakesh</td> <td>January</td> <td>15000/-Rs.</td>
</tr>
<tr>
<td>Ram</td> <td>January</td> <td>12000/-RS.</td>
</tr>
</table>
</body> </html>
Result:-
e.g.2
There are two attribiutes cellpadding and cellspacing which can use to adjust the white space in your table cell. Cellspacing defines the width of the border, while cellpadding specifies the distance between cell borders and the content within.
<!DOCTYPE html>
<html>
<head>
<title>use of td tag</title>
</head>
<body>
<table border="1" cellpadding="16">
<tr>
<th>Month</th> <th>Savings</th>
</tr>
<tr>
<td>January</td> <td>$100</td>
</tr>
</table>
</body>
</html>
Result:-
e.g.2.1
<!DOCTYPE html>
<html>
<head>
<title>use of td tag</title>
</head>
<body>
<table border="1" cellpadding="16" cellspacing="5">
<tr>
<th>Month</th> <th>Savings</th>
</tr>
<tr>
<td>January</td> <td>$100</td>
</tr>
</table>
</body>
</html>
Result:-
<!DOCTYPE html>
<html>
<head>
<title>use of td tag</title>
</head>
<body>
<table border="1">
<tr>
<th>Name</th> <th>month</th> <th>Income</th>
</tr>
<tr>
<td>Rakesh</td> <td>January</td> <td>15000/-Rs.</td>
</tr>
<tr>
<td>Ram</td> <td>January</td> <td>12000/-RS.</td>
</tr>
</table>
</body> </html>
Result:-
Name | month | Income |
---|---|---|
Rakesh | January | 15000/-Rs. |
Ram | January | 12000/-Rs. |
e.g.2
There are two attribiutes cellpadding and cellspacing which can use to adjust the white space in your table cell. Cellspacing defines the width of the border, while cellpadding specifies the distance between cell borders and the content within.
<!DOCTYPE html>
<html>
<head>
<title>use of td tag</title>
</head>
<body>
<table border="1" cellpadding="16">
<tr>
<th>Month</th> <th>Savings</th>
</tr>
<tr>
<td>January</td> <td>$100</td>
</tr>
</table>
</body>
</html>
Result:-
Month | Savings |
---|---|
January | $100 |
e.g.2.1
<!DOCTYPE html>
<html>
<head>
<title>use of td tag</title>
</head>
<body>
<table border="1" cellpadding="16" cellspacing="5">
<tr>
<th>Month</th> <th>Savings</th>
</tr>
<tr>
<td>January</td> <td>$100</td>
</tr>
</table>
</body>
</html>
Result:-
Month | Savings |
---|---|
January | $100 |
Conclusion:--
So the <td> tag is used to define a row in an HTML table in a webpage.<td> and <th> tags are important for table designing in webpage.
No comments:
Post a Comment