Why colspan is used in html tables?? | Sololearn: Learn to code for FREE!


Why colspan is used in html tables??

7/25/2017 9:52:27 AM

Shubhadip Chattaraj

2 Answers

New Answer


'colspan' is used to set the number of cells IN A ROW to merge... 'rowspan' is used as well to set number of cells merged in a column... Merged cells don't have to be write in the code: <table> <tr> <td>cell content</td> <td colspan="2">cell content</td> <td>cell content</td> <!-- only 3 td elements, but virtually 4 --> </tr> <tr> <!-- in a row without merged cells, we need as much td element than virtual number in rows with merged cells --> <td>cell content</td> <td>cell content</td> <td>cell content</td> <td>cell content</td> </tr> <!-- same rule applied in case of rowspan, but virtual cells are in column --> </table>


colspan attribute is used to expand a cell for two or more cells