Click here to Skip to main content
14,573,479 members
Rate this:
Please Sign up or sign in to 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:

<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
Rate this:
Please Sign up or sign in to vote.

Solution 2

Try this-
<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 :)
   
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?
Rate this:
Please Sign up or sign in to vote.

Solution 1

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.
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100