
- HTML Tutorial
- HTML - Home
- HTML - Roadmap
- HTML - Introduction
- HTML - History & Evolution
- HTML - Editors
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Headings
- HTML - Paragraphs
- HTML - Fonts
- HTML - Blocks
- HTML - Style Sheet
- HTML - Formatting
- HTML - Quotations
- HTML - Comments
- HTML - Colors
- HTML - Images
- HTML - Image Map
- HTML - Frames
- HTML - Iframes
- HTML - Phrase Elements
- HTML - Code Elements
- HTML - Meta Tags
- HTML - Classes
- HTML - IDs
- HTML - Backgrounds
- HTML Tables
- HTML - Tables
- HTML - Table Headers & Captions
- HTML - Table Styling
- HTML - Table Colgroup
- HTML - Nested Tables
- HTML Lists
- HTML - Lists
- HTML - Unordered Lists
- HTML - Ordered Lists
- HTML - Definition Lists
- HTML Links
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML Color Names & Values
- HTML - Color Names
- HTML - RGB & RGBA Colors
- HTML - HEX Colors
- HTML - HSL & HSLA Colors
- HTML - HSL Color Picker
- HTML Forms
- HTML - Forms
- HTML - Form Attributes
- HTML - Form Control
- HTML - Input Attributes
- HTML Media
- HTML - Video Element
- HTML - Audio Element
- HTML - Embed Multimedia
- HTML Header
- HTML - Head Element
- HTML - Adding Favicon
- HTML - Javascript
- HTML Layouts
- HTML - Layouts
- HTML - Layout Elements
- HTML - Layout using CSS
- HTML - Responsiveness
- HTML - Symbols
- HTML - Emojis
- HTML - Style Guide
- HTML Graphics
- HTML - SVG
- HTML - Canvas
- HTML APIs
- HTML - Geolocation API
- HTML - Drag & Drop API
- HTML - Web Workers API
- HTML - WebSocket
- HTML - Web Storage
- HTML - Server Sent Events
- HTML Miscellaneous
- HTML - Document Object Model (DOM)
- HTML - MathML
- HTML - Microdata
- HTML - IndexedDB
- HTML - Web Messaging
- HTML - Web CORS
- HTML - Web RTC
- HTML Demo
- HTML - Audio Player
- HTML - Video Player
- HTML - Web slide Desk
- HTML Tools
- HTML - Velocity Draw
- HTML - QR Code
- HTML - Modernizer
- HTML - Validation
- HTML - Color Picker
- HTML References
- HTML - Cheat Sheet
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Character Entities
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
- HTML Resources
- HTML - Quick Guide
- HTML - Useful Resources
- HTML - Color Code Builder
- HTML - Online Editor
HTML - <td> Tag
Introduction to <td> Tag
The HTML <td> tag is used to define the table data in a table. It is the key component in building structured tabular content. The <td> tag must be used within a <tr> element, which groups one or more table cells. It can contains the text, images, links or other HTML elements.
By default, the text inside the <td> is aligned to the left horizontally and to the middle vertically, but this can be customized by using the CSS.
Syntax
Following is the syntax of HTML <td> tag −
<table> <tr> <td>..</td> <td>..</td> ... </tr> </table>
Attributes
Following are the attributes of the <tg> Tag −
Attribute | Value | Description |
---|---|---|
colspan | number | Specifies the number of columns. |
headers | header_id | Specifies one or more header cells a cell is related to. |
rowspan | number | Specifies the number of rows a cell should take. |
Example : Basic Table
Let's look at the following example, where we are going to consider the basic usage of the <td> tag.
<!DOCTYPE html> <html> <style> table, th, td { border: 2px solid #5DADE2; } </style> <body> <table> <tr> <td>1</td> <td>2</td> </tr> <tr> <td>3</td> <td>4</td> </tr> <tr> <td>5</td> <td>6</td> </tr> </table> </body> </html>
Example : Using colspan Attribute
Consider the following example, where we are going to use the colspan attribute along with the <td> tag.
<!DOCTYPE html> <html> <style> table, th, td { border: 1.5px solid #A569BD; } </style> <body> <table> <tr> <th>Stundent</th> <th>Age</th> </tr> <tr> <td style="background-color:#BFC9CA">Ram</td> <td style="background-color:#F9E79F ">23</td> </tr> <tr> <td style="background-color:#BFC9CA ">Raju</td> <td style="background-color:#F9E79F ">22</td> </tr> </table> </body> </html>
Example : Uisng rowspan Attribute
In the following example, we are going to use the rowspan attribute along with the <td> tag.
<!DOCTYPE html> <html> <style> table, th, td { border: 1px solid black; color:green; } </style> <body> <table> <tr> <th>Company</th> <th>Location</th> <th>Founder</th> </tr> <tr> <td>tutorialspoint</td> <td>hyderabad</td> <td rowspan="2">MD.Mohtashim</td> </tr> <tr> <td>tutorix</td> <td>Noida</td> </tr> </table> </body> </html>
Supported Browsers
Tag | ![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|---|
tbody | Yes | Yes | Yes | Yes | Yes |