HTML <td> tag

HTML <td> tag

The <td> tag specifies a data cell in an HTML table.

There are two kinds of cells available for an HTML table.

  • <th> (header cell) - contains column heading.
  • <td> (data cell) - contains table data.

Note: By default, the text inside the <td> element are regular and left-aligned.

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <table> <tr> <th>S.No</th> <th>Name</th> </tr> <tr> <td>1</td> <td>Brendan</td> </tr> <tr> <td>2</td> <td>Eich</td> </tr> </table> </body> </html>

Attributes

The following are the attributes of <td> tag. Also try Global attributes.

AttributeValueExplanation
colspannumberSpecifies how many columns the <td> element should extend.
headerstextContains a list of space-separated strings, each corresponding to the id attribute of the <th> elements that apply to this element.
rowspannumberSpecifies how many rows the <td> element should extend.

Deprecated Attributes

The following attributes should not be used in any case.

AttributeValueExplanation
abbrtextSpecifies an abbreviated description of the content in a <td> element.
align
  • left
  • center
  • right
  • justify
  • char
Specifies the horizontal alignment of the content in a <td> element.
axisIDSpecifies a grouping of cell.
bgcolor
  • color name
  • #RRGGBB
Specifies the background color of a <td> element.
charcharacterSpecifies a character to align the content inside <td> element.
charoffnumberSpecifies the number of characters to offset the <td> data from the alignment characters specified by the char attribute.
heightpxSpecifies the height of the <td> element.
scope
  • row
  • col
  • rowgroup
  • colgroup
  • auto
Defines a relationship between the <th> element and <td> element.
valign
  • baseline
  • bottom
  • middle
  • top
Specifies the vertical alignment of the content in the <td> element.
widthpxSpecifies the width of the <td> element.

Reminder

Hi Developers, we almost covered 99.5% of HTML Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in HTML.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Meet the Author