
- 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 - <tbody> Tag
Introduction to <tbody> Tag
The HTML <tbody> tag is used to group the body content of the table. It is useful when a table contains multiple sectios, such as a header (<thead>), body (<tbody>) and footer (<tfoot>).
The <tbody> tag ensures that the table rows (<tr>) containing the main data are semantically seperate from the header and footer rows. By default, the browser assumes all rows belong to <tbody> unless specified otherwise.
Syntax
Following is the syntax of HTML <tbody> tag −
<tbody> ... </tbody>
Attributes
HTML tbody tag supports Global and Event attributes of HTML. Bellow mentioned attributes are deprecated so use CSS properties rather using these attributes.
Attribute | Value | Description |
---|---|---|
align | left right center justify |
Specifies the alignment of text content(Deprecated). |
bgcolor | color | Specifies the background color of each column cell(Deprecated). |
char | character | Specifies the alignment of the content to a character of each column cell(Deprecated). |
charoff | number | Specifies the number of characters to offset the column cell content from the alignment character specified by the char attribute(Deprecated). |
valign | baseline bottom middle top |
Specifies the vertical alignment of each column cell(Deprecated). |
Example : Basic Usage
Let's look at the following example, where we are going to consider the basic usage of the <tbody> tag.
<!DOCTYPE html> <html> <body> <table border="1"> <thead> <tr> <th>ID</th> <th>NAME</th> </tr> </thead> <tbody> <tr> <td>1567</td> <td>Maya</td> </tr> <tr> <td>1566</td> <td>Ram </td> </tr> <tr> <td>1564</td> <td>Rahul</td> </tr> </tbody> </table> </body> </html>
Example : Styling <tbody> Rows
Consider the following example, where we are going to apply the CSS properties to the <tbody> row.
<!DOCTYPE html> <html> <style> th, td { padding: 9px; border: 1.5px solid #DE3163; } tbody tr:nth-child(odd) { background-color: #c39bd3; } </style> <body> <table style="width:50%; border-collapse:collapse;"> <thead> <tr> <th>Items</th> <th>Price</th> </tr> </thead> <tfoot> <tr> <td>Total</td> <td>1100</td> </tr> </tfoot> <tbody> <tr> <td>Chocolates</td> <td>200</td> </tr> <tr> <td>Grocessary</td> <td>900</td> </tr> </tbody> </table> </body> </html>
Example : Aligning Body Content
In the following example, we are going to make the content inside the <tbody> to the center using CSS.
<!DOCTYPE html> <html> <style> table, th, td { border: 1.5px solid #A569BD; } </style> <body> <table style="width:50%"> <thead> <tr> <th>Students</th> <th>Marks</th> </tr> </thead> <tbody style="text-align:center"> <tr> <td>Maya</td> <td>75</td> </tr> <tr> <td>Raj</td> <td>76</td> </tr> <tr> <td>Suresh</td> <td>77</td> </tr> </tbody> </table> </body> </html>
Supported Browsers
Tag | ![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|---|
tbody | Yes | Yes | Yes | Yes | Yes |