HTML <td> Tag
In this tutorial, we will learn about td tag in HTML with the help of examples.
<td> Tag
Td tag <td> is used to specify a cell or table data within a table.
Syntax
<td>..........</td>
Example
<!DOCTYPE html>
<html>
<head>
<title>td tag</title>
</head>
<body>
<table>
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr>
<td>Sunny</td>
<td>Chaudhary</td>
<td>20</td>
</tr>
<tr>
<td>Anu</td>
<td>Chaudhary</td>
<td>19</td>
</tr>
</tbody>
</table>
</body>
</html>
Output
Specific Attribute
Attribute | Value | Description |
---|---|---|
abbr | abbreviated_text | It specifies an abbreviated version of the content in a cell |
align | right left center justify char |
It is used for visual alignment |
bgcolor | rgb(x,x,x) #hexcode color_name |
It specifies the background color of the table |
cellpadding | pixels percentage(%) |
It specifies the space between the cell borders and their contents |
char | character | It specifies which character to align text on align = char |
charoff | pixels percentage(%) |
It specifies an alignment offset(either in pixels or percentage value) against the first character as specified with the char attribute. It is used when align = char |
colspan | number | It specifies the number of columns the current cell spans accross |
header | height | It specifies a space-seperated list of header cells that contain information about this cell. The value needs to correspond with the id of the header cell(which is set using the id attribute). This attribute is useful for non-visual browsers |
nowrap | nowrap | It is used to prevents text from automatically wrapping |
rowspan | numbers | It is used to specify the number of rows the current cell spans across |
valign | top middle bottom baseline |
It is used for vertical alignment |
width | pixels percentage(%) |
It is used to specify the width of the table |
Global Attribute
Td Tag support all the global attributes of HTML.
Event Attribute
Td Tag support all the event attributes of HTML.
Next Tutorial
We hope that this tutorial helped you develop better understanding of the concept of <td> tag in HTML.
Keep Learning : )
In the next tutorial, you'll learn about HTML <template>
Tag.