![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML colspan Attribute
The colspan attribute of the <td> element in HTML defines the number of columns a cell should span.
Following is the syntax −
<td colspan="num">
Above, num is the count of columns a cell should span.
Let us now see an example to implement the colspan attribute of the <td> element −
Example
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 2px solid blue;
}
</style>
</head>
<body>
<h2>Product Expenses</h2>
<table>
<tr>
<th>Domains</th>
<th>Cost</th>
</tr>
<tr>
<td>Product Development</td>
<td>500000</td>
</tr>
<tr>
<td>Marketing</td>
<td>500000</td>
</tr>
<tr>
<td>Services</td>
<td>100000</td>
</tr>
<tr>
<td>Support</td>
<td>100000</td>
</tr>
<tr>
<td>Maintenance</td>
<td>100000</td>
</tr>
<tr>
<td colspan="2">Total Budget = INR 1300000</td>
</tr>
</table>
</body>
</html>
Output
![](https://www.tutorialspoint.com/assets/questions/media/24435/table.jpg)
Advertisements
The colspan attribute of the <td> element in HTML defines the number of columns a cell should span.
Following is the syntax −
<td colspan="num">
Above, num is the count of columns a cell should span.
Let us now see an example to implement the colspan attribute of the <td> element −
Example
<!DOCTYPE html> <html> <head> <style> table, th, td { border: 2px solid blue; } </style> </head> <body> <h2>Product Expenses</h2> <table> <tr> <th>Domains</th> <th>Cost</th> </tr> <tr> <td>Product Development</td> <td>500000</td> </tr> <tr> <td>Marketing</td> <td>500000</td> </tr> <tr> <td>Services</td> <td>100000</td> </tr> <tr> <td>Support</td> <td>100000</td> </tr> <tr> <td>Maintenance</td> <td>100000</td> </tr> <tr> <td colspan="2">Total Budget = INR 1300000</td> </tr> </table> </body> </html>
Output
Advertisements