Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
HI everyone ,

As i am new in html .I am confused in rowspan and colspan. i want landline cell below the old number cell.any idea please let me know. I wrote the code as follows:

XML
<table border="1">

<tr>
<td> harshal</td>
<td> Raut</td>
<td> mobile</td>
<td rowspan=""> address</td>
<td>old number</td>
</tr>
<tr>
<td  colspan="1">new number</td>
<td> landline</td>
</tr>
</table>



Thanks
Posted

Here's a good tutorial on the how ROWSPAN and COLSPAN work, http://www.htmlcodetutorial.com/tables/index_famsupp_30.html[^]

If you think of the table as an excel file that may help. Looking at your first row, (tr), you have 5 cells (5 tds.) None of them have a colspan so you have 5 columns in the first row. Old number is in your last column. So, if you want new number to be below it you have several options depending on how you want it to look.

You could have that single cell and colspan it 5 which means that one cell will take up all 5 columns. You then could align="right" so that the text is all the way to the right, so it lines up under the last cell.

However, a better approach, would be to put a td before your landline one and make it colspan 4 so that it fills up the first 4 columns. Then your landline would be the 5th column lining it up with old number (if I counted right).

It may help to use Excel to built it out first or possibly just draw it on a piece of paper. Even us experienced guys have to draw it out first sometimes to make sure it looks right visually.
 
Share this answer
 
Try this-
HTML
<table border="1"> 
<tr>
<td> harshal</td>
<td> Raut</td>
<td> mobile</td>
<td> address</td>
<td>old number</td>
</tr>
<tr>
<td colspan="4">new number</td>
<td> landline</td>
</tr>
</table>


check the result here: https://jsfiddle.net/mr8trjvh/[^]

Is this what you need ?

Hope, it helps :)
 
Share this answer
 
Comments
R Harshal 27-Oct-15 9:38am    
it showing the cell blank below mobile and address which not required..Any idea.
Suvendu Shekhar Giri 28-Oct-15 0:44am    
what you need to show there then?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900