td HTML

HTML <td> Tag

To define the data cells of an HTML table the HTML <td> tag is used as the child element of <tr> (table row) tag. These cells are used to place data of the table. Multiple <td> data elements can be placed within an HTML <tr> tag. Within a <tr> tag, the grouped <td> elements are displayed as a single row in the table. By default, it displays the data as regular and left-aligned in the table.

Syntax:

<td>.......</td>

Example:

<!DOCTYPE html>
<html>
<body>
<h3>Students Table</h3>
<table style="width:50%" border="2">
  <tr>
    <th>NAME</th>
    <th>AGE</th> 
    <th>CITY</th>
  </tr>
  <tr>
    <td>Tom</td>
    <td>10</td>
    <td>London</td>
  </tr>
  <tr>
    <td>Jerry</td>
    <td>8</td>
    <td>London</td>
  </tr>
  <tr>
    <td>Bruno</td>
    <td>12</td>
    <td>Wells</td>
  </tr>
</table>
</body>
</html>

Output:

Explanation:

In the above example, a table is created with three header cells namely, “NAME,” “AGE”, and “CITY”. Here, the width of the table is also defined to be 50%. A border is added to the table of size 2 pixels using the border attribute of the HTML table.

Tag specific Attributes:

Attribute Value Uses HTML 5
abbr text Used to define the abbreviated version of the cell content. Not supported in HTML5.
align left

right

center

justify

char

Used to align a cell content. Not supported in HTML5.
axis category_name Used to categorize cells. Not supported in HTML5.
bgcolor rgb(x,x,x)

#xxxxxx

colorname

Used to define the background color of a cell. Not supported in HTML5.
char character Used to align a cell content to a character. Not supported in HTML5.
charoff number Used to define the number of characters the content will be aligned from the character specified by the char attribute. Not supported in HTML5.
colspan number Used to indicate the number of columns a cell should span.
headers header_id Used to indicate one or more header cells a cell is related to.
height pixels

Used to define the height of a cell. Not supported in HTML5.
nowrap nowrap Used to instruct that the content inside a cell should not wrap. Not supported in HTML5.
rowspan number Used to define the number of rows a cell should span.
scope col

colgroup

row

rowgroup

Used to define a way to associate header cells and data cells in a table. Not supported in HTML5.
valign top

middle

bottom

baseline

Used to vertically align the content in a cell. Not supported in HTML5.
width pixels

Used to define the width of a cell. Not supported in HTML5.

Global Attributes:

The HTML Global attributes are supported by the HTML <td> tag.

Event Attributes:

The HTML Event attributes are supported by the HTML <td> tag.

Supporting Browser:

Chrome, IE, Firefox, Opera and Safari.

Please Share