HTML td Tag

HTML <td>Tag: The HTML<td> tag specifies a standard cell in an HTML table. HTML td tag contains table data. An HTML table has two kinds of cells:

  • Header cells – contains header information (created with the <th> element)
  • Standard cells – contains data (created with the <td> element)

And the text in <th> elements are bold and centered by default. While the <td> elements are regular and left-aligned by default.

HTML <td>Tag

This HTML td tag supports both the global and the event attributes. And the colspan attribute when used with <td> tag determines the number of standard cells it should span.



Syntax: <td> Text </td>

Browser compatibility

The HTML<td> tag is supported by different types of browsers.

  • Chrome
  • Firefox
  • Opera
  • Safari
  • Internet Explorer

Example:

<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
  border: 1px solid black;
}
</style>
</head>
<body>

<table>
  <tr>
    <td>JAVASCRIPT</td>
    <td>Scripting Language</td>
  </tr>
</table>

</body>
</html>

Output:

html td tag

Attributes that are supported by the <td> tag

Attribute Value Description
align left
center
right
justify
char
Aligns the content in a cell
abbr text Specifies an abbreviated version of the content in a cell
axis category_name Categories cells
valign top
middle
bottom
baseline
Vertical aligns the content in a cell
char character Aligns the content in a cell to a character
charoff number Sets the number of characters the content will be aligned from the character specified by the char attribute
colspan number Specifies the number of columns a cell should span
headers header_id Specifies one or more header cells a cell is related to
height pixels
%
Sets the height of a cell
nowrap nowrap Specifies that the content inside a cell should not wrap
rowspan number Sets the number of rows a cell should span
scope col
colgroup
row
rowgroup
Defines a way to associate header cells and data cells in a table
width pixels
%
Specifies the width of a cell