Page 1 of 1

HTML Table Colspan & Rowspan

Posted: Fri Oct 27, 2023 8:05 am
by Guest
HTML Table Colspan & Rowspan


HTML tables can have cells that span over multiple rows and/or columns.




NAME
 


 
 
 


 
 
 


 
 
 


 
 
 




APRIL
 
 


 
 


 
 


 
 
 


 
 
 




2022


 
 
 


FIESTA
 


 


 
 
 




HTML Table - Colspan
To make a cell span over multiple columns, use the colspan attribute:

Example

<table>  <tr>    <th colspan="2">Name</th>   
<th>Age</th>  </tr>  <tr>   
<td>Jill</td>    <td>Smith</td>   
<td>43</td>  </tr>  <tr>    <td>Eve</td>   
<td>Jackson</td>    <td>57</td>  </tr></table>
Try it Yourself »


Note: The value of the colspan attribute represents the number of columns to span.


HTML Table - Rowspan
To make a cell span over multiple rows, use the rowspan attribute:

Example

<table>  <tr>    <th>Name</th>   
<td>Jill</td>  </tr>  <tr>    <th rowspan="2">Phone</th>   
<td>555-1234</td>  </tr>  <tr>   
<td>555-8745</td></tr></table>
Try it Yourself »


Note: The value of the rowspan attribute represents the number of
rows to span.








HTML Exercises

Test Yourself With Exercises

Exercise:
Use the correct HTML attribute to make the first TH element span two columns.


<table>

  <tr>

    <th >Name</th>

    <th>Age</th>

  </tr>

  <tr>

    <td>Jill</td>

    <td>Smith</td>

    <td>50</td>

  </tr>

  <tr>

    <td>Eve</td>

    <td>Jackson</td>

    <td>94</td>

  </tr>

</table>


Submit Answer »
Start the Exercise
















+1

Reference: https://www.w3schools.com/html/html_tab ... owspan.asp