- HTML Tutorial
- HTML - Home
- HTML - History and Evolution
- HTML - Overview
- HTML - Editors
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Headings
- HTML - Paragraphs
- HTML - Quotations
- HTML - Comments
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Style Sheet
- HTML - CSS Classes
- HTML - CSS IDs
- HTML - Images
- HTML - Image Map
- HTML Tables
- HTML - Tables
- HTML - Headers & Caption
- 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 - Iframes
- HTML - Blocks
- HTML Backgrounds
- HTML - Backgrounds
- HTML Colors
- HTML - Colors
- HTML - RGB
- HTML - HEX
- HTML - HSL
- 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 - 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 Code Builder
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - 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 - rowspan Attribute
The rowspan is an HTML attribute that specifies the number of rows spanned by a cell or grid cell within a table or grid.
If a row spans two rows, it represents it will take up two rows in that table. It is similar to the merge cell in a spreadsheet program such as Excel. And it allows a single table cell to span the height of many cells or rows.
Following is the element where the rowspan attribute can be used −
- <td>
- <th>
Syntax
Following is the syntax of the rowspan attribute −
<th|td rowspan="2 | 3 | 4, …" >
Example
In the following example, we are demonstrating the usage of the rowspan within the <td> element to span the rows by 2.
<!DOCTYPE html> <html> <head> <style> table, th, td { border: 1px solid black; } </style> </head> <body> <h1>The td rowspan attribute</h1> <table> <tr> <th>Company</th> <th>Location</th> <th>Managment</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>
On running the above code, it will generate an output consisting of the table filled with data displayed on the webpage.
Example
Considering the another scenario, where we are going to use the rowspan with the th element to span the rows by 2.
<!DOCTYPE html> <html> <head> <style> th { background-color: gray; } td { border: 1px solid black; background-color: pink; } </style> </head> <body> <h1>The th rowspan attribute</h1> <table> <tr> <th rowspan="2">Name of Student</th> <th rowspan="2">Company</th> <th rowspan="2">Location</th> </tr> <tr></tr> <tr> <td>Aman Kumar</td> <td>tutorialspoint</td> <td>Hyderabad</td> </tr> <tr> <td>Akash Kumar</td> <td>Ltts</td> <td>Mysore</td> </tr> </table> </body> </html>
When we run the above code, it will generate an output consisting of the table filled with data along with a CSS applied displayed on the webpage.
Example
Let's look into the following example, where we are going to use the rowspan with the th element to span the rows by 3.
<!DOCTYPE html> <html> <head> <style> th { background-color: gray; } td { border: 1px solid black; background-color: pink; } </style> </head> <body> <h1>The th rowspan attribute</h1> <table> <tr> <th rowspan="3">tutorialspoint</th> <th>Employees</th> <th>Designation</th> </tr> <tr> <td>Aman Kumar</td> <td>technical content writer</td> </tr> <tr> <td>Vivek Kumar</td> <td>Developer</td> </tr> </table> </body> </html>
On running the above code, the output window will pop up displaying the table on the webpage.
To Continue Learning Please Login
Login with Google