Link to home
Start Free TrialLog in
Avatar of kaushalk
kaushalkFlag for United States of America

asked on

Creating Tables on Webpage

So, I have a blank page and I want to split the page with rows and colums by creating tables.  I did so just fine.  My real problem is:

when i create next row and split that row with 2 or 3 colums, they seem to move with the above row and column.  I unable to keep the above row and column fixed while i move the next row and column to fit my needs

is there anyway to fix a certain rows properties while the column in the next row is being changed?
Avatar of rbudj
rbudj
Flag of United States of America image

Can you display your code? Keep in mind though that you need to specify a width for each data cell that equals the total width of the table including any borders and padding.
Avatar of kaushalk

ASKER

This is just part of the code from the beginning
<table id="Table_01" width="1000" height="526" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr>
		<td height="397" colspan="4"><img src="images/General_01.gif" width="1000" height="397" alt=""></td>
	</tr>
	<tr>
		<td height="41" colspan="4">
			<img src="images/General_02.gif" width="1000" height="41" alt=""></td>
	</tr>
	<tr>
	  <td colspan="4" bgcolor="#e3f3bc">&nbsp;</td>
  </tr>
	<tr>
	  <td colspan="4" align="center" bgcolor="#e3f3bc"><span style="font-size: 20px; font-family: 'Trebuchet MS', Arial, Helvetica, sans-serif;"><strong>Duct Cleaning: The Rotobrush Way</strong></span></td>
  </tr>
	<tr>
	  <td colspan="4" bgcolor="#e3f3bc">&nbsp;</td>
  </tr>
	<tr>
	  <td width="82" bgcolor="#e3f3bc">&nbsp;</td>
	  <td colspan="2" bgcolor="#e3f3bc">What's inside my Duct?</td>
	  <td width="79" bgcolor="#e3f3bc">&nbsp;</td>
  </tr>
	<tr>
	  <td bgcolor="#e3f3bc">&nbsp;</td>
	  <td colspan="2" bgcolor="#e3f3bc">Most people would gag if they could see what's inside their homes' ductwork. Here are just a few of the allergens, pathogens, and irritants commonly found inside HVAC ducts:</td>
	  <td bgcolor="#e3f3bc">&nbsp;</td>
  </tr>
	<tr>
	  <td colspan="4" bgcolor="#e3f3bc">&nbsp;</td>
  </tr>
	<tr>
	  <td bgcolor="#e3f3bc">&nbsp;</td>
	  <td width="229" bgcolor="#e3f3bc"><img src="images/ltgrnball.gif" width="15" height="15" align="absmiddle"> Dust</td>
	  <td width="610" bgcolor="#e3f3bc">&nbsp;</td>
	  <td bgcolor="#e3f3bc">&nbsp;</td>
  </tr>
	<tr>
	  <td bgcolor="#e3f3bc">&nbsp;</td>
	  <td bgcolor="#e3f3bc"><img src="images/ltgrnball.gif" alt="" width="15" height="15" align="absmiddle"> Dirt</td>
	  <td bgcolor="#e3f3bc">&nbsp;</td>
	  <td bgcolor="#e3f3bc">&nbsp;</td>
  </tr>
	<tr>
	  <td bgcolor="#e3f3bc">&nbsp;</td>
	  <td bgcolor="#e3f3bc"><img src="images/ltgrnball.gif" alt="" width="15" height="15" align="absmiddle"> Soil</td>
	  <td bgcolor="#e3f3bc">&nbsp;</td>
	  <td bgcolor="#e3f3bc">&nbsp;</td>
  </tr>
	<tr>
	  <td bgcolor="#e3f3bc">&nbsp;</td>
	  <td bgcolor="#e3f3bc"><img src="images/ltgrnball.gif" alt="" width="15" height="15" align="absmiddle"> Animal Dander</td>
	  <td bgcolor="#e3f3bc">&nbsp;</td>
	  <td bgcolor="#e3f3bc">&nbsp;</td>
  </tr>

Open in new window

Noticed you are missing the end </tr></table> tags. In adding them back I am looking at your table. What row are you working on and what are you trying to do with it?
so let's say i want to add an image in one of the colums, well the column width moves to fit the image but it also shift the columns above and below the row that i am working with
Yes. This is correct. This is the way tables work. If you did not want the cell to expand, the first thing you want to do is make sure you do not put an oversized image in the cell. If that is not possible then you will need to combine the cells in the other top or bottom rows, and then nest (insert a new table) inside that column to have stagering cells as compared to the rest of the table. Try the code below. I took the first "Dirt" row and nested a table. Now if you insert an oversized image next to the second Dirt, you will notice the row above keep its column widths.
<table id="Table_01" width="1000" height="526" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr>
		<td height="397" colspan="4"><img src="images/General_01.gif" width="1000" height="397" alt=""></td>
	</tr>
	<tr>
		<td height="41" colspan="4">
			<img src="images/General_02.gif" width="1000" height="41" alt=""></td>
	</tr>
	<tr>
	  <td colspan="4" bgcolor="#e3f3bc">&nbsp;</td>
  </tr>
	<tr>
	  <td colspan="4" align="center" bgcolor="#e3f3bc"><span style="font-size: 20px; font-family: 'Trebuchet MS', Arial, Helvetica, sans-serif;"><strong>Duct Cleaning: The Rotobrush Way</strong></span></td>
  </tr>
	<tr>
	  <td colspan="4" bgcolor="#e3f3bc">&nbsp;</td>
  </tr>
	<tr>
	  <td width="82" bgcolor="#e3f3bc">&nbsp;</td>
	  <td colspan="2" bgcolor="#e3f3bc">What's inside my Duct?</td>
	  <td width="79" bgcolor="#e3f3bc">&nbsp;</td>
  </tr>
	<tr>
	  <td bgcolor="#e3f3bc">&nbsp;</td>
	  <td colspan="2" bgcolor="#e3f3bc">Most people would gag if they could see what's inside their homes' ductwork. Here are just a few of the allergens, pathogens, and irritants commonly found inside HVAC ducts:</td>
	  <td bgcolor="#e3f3bc">&nbsp;</td>
  </tr>
	<tr>
	  <td colspan="4" bgcolor="#e3f3bc">&nbsp;</td>
  </tr>
	<tr>
	  <td bgcolor="#e3f3bc">&nbsp;</td>
	  <td colspan="2" bgcolor="#e3f3bc"><img src="images/ltgrnball.gif" width="15" height="15" align="absmiddle">
      <table>
      <tr><td width="229">Dirt</td>
      <td width="610"></td>
      </tr>
      </table>
      </td>
	  <td bgcolor="#e3f3bc">&nbsp;</td>
  </tr>
	<tr>
	  <td bgcolor="#e3f3bc">&nbsp;</td>
	  <td width="229" bgcolor="#e3f3bc"><img src="images/ltgrnball.gif" alt="" width="15" height="15" align="absmiddle"> Dirt</td>
	  <td width="610" bgcolor="#e3f3bc">&nbsp;</td>
	  <td bgcolor="#e3f3bc">&nbsp;</td>
  </tr>
	<tr>
	  <td bgcolor="#e3f3bc">&nbsp;</td>
	  <td bgcolor="#e3f3bc"><img src="images/ltgrnball.gif" alt="" width="15" height="15" align="absmiddle"> Soil</td>
	  <td bgcolor="#e3f3bc">&nbsp;</td>
	  <td bgcolor="#e3f3bc">&nbsp;</td>
  </tr>
	<tr>
	  <td bgcolor="#e3f3bc">&nbsp;</td>
	  <td bgcolor="#e3f3bc"><img src="images/ltgrnball.gif" alt="" width="15" height="15" align="absmiddle"> Animal Dander</td>
	  <td bgcolor="#e3f3bc">&nbsp;</td>
	  <td bgcolor="#e3f3bc">&nbsp;</td>
      </tr>
      </table>

Open in new window

OK.  so i got the image fine.  please see attached image for visual explanation

if i move column B, it also moves column C or on the other side, if i move column A, it also moves column D.  how do i fix that?
Columns.pdf
That is correct. This is the way tables are. If you have one table and you specifiy the width for a data cell, that width will be applied to all other data cells in that table. The only way around this is to nest your tables. See this code. I did this for you in the D line. Try moving the other cells now and you will notice the nested table retains its cell widths.
<table id="Table_01" width="1000" height="526" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr>
		<td height="397" colspan="4"><img src="images/General_01.gif" width="1000" height="397" alt=""></td>
	</tr>
	<tr>
		<td height="41" colspan="4">
			<img src="images/General_02.gif" width="1000" height="41" alt=""></td>
	</tr>
	<tr>
	  <td colspan="4" bgcolor="#e3f3bc">&nbsp;</td>
  </tr>
	<tr>
	  <td colspan="4" align="center" bgcolor="#e3f3bc"><span style="font-size: 20px; font-family: 'Trebuchet MS', Arial, Helvetica, sans-serif;"><strong>Duct Cleaning: The Rotobrush Way</strong></span></td>
  </tr>
	<tr>
	  <td colspan="4" bgcolor="#e3f3bc">&nbsp;</td>
  </tr>
	<tr>
	  <td width="82" bgcolor="#e3f3bc">&nbsp;</td>
	  <td colspan="2" bgcolor="#e3f3bc">What's inside my Duct?</td>
	  <td width="79" bgcolor="#e3f3bc">&nbsp;</td>
  </tr>
	<tr>
	  <td colspan="4" bgcolor="#e3f3bc">
      <table width="1000">
      <tr>
      <td width="82">k</td>
      <td>Most people would gag if they could see what's inside their homes' ductwork. Here are just a few of the allergens, pathogens, and irritants commonly found inside HVAC ducts:</td>
      <td width="79">d</td>
      </tr>
      </table>
      </td>
  </tr>
	<tr>
	  <td colspan="4" bgcolor="#e3f3bc">&nbsp;</td>
  </tr>
	<tr>
	  <td bgcolor="#e3f3bc">&nbsp;</td>
	  <td colspan="2" bgcolor="#e3f3bc"><img src="images/ltgrnball.gif" width="15" height="15" align="absmiddle">
      <table>
      <tr><td width="229">Dirt</td>
      <td width="610"></td>
      </tr>
      </table>
      </td>
	  <td bgcolor="#e3f3bc">&nbsp;</td>
  </tr>
	<tr>
	  <td bgcolor="#e3f3bc">&nbsp;</td>
	  <td width="229" bgcolor="#e3f3bc"><img src="images/ltgrnball.gif" alt="" width="15" height="15" align="absmiddle"> Dirt</td>
	  <td width="610" bgcolor="#e3f3bc">&nbsp;</td>
	  <td bgcolor="#e3f3bc">&nbsp;</td>
  </tr>
	<tr>
	  <td bgcolor="#e3f3bc">&nbsp;</td>
	  <td bgcolor="#e3f3bc"><img src="images/ltgrnball.gif" alt="" width="15" height="15" align="absmiddle"> Soil</td>
	  <td bgcolor="#e3f3bc">&nbsp;</td>
	  <td bgcolor="#e3f3bc">&nbsp;</td>
  </tr>
	<tr>
	  <td bgcolor="#e3f3bc">&nbsp;</td>
	  <td bgcolor="#e3f3bc"><img src="images/ltgrnball.gif" alt="" width="15" height="15" align="absmiddle"> Animal Dander</td>
	  <td bgcolor="#e3f3bc">&nbsp;</td>
	  <td bgcolor="#e3f3bc">&nbsp;</td>
      </tr>
      </table>

Open in new window

btw, I will go ahead and be the first to say that you should not be using tables for layouts. If you are new to tables, you should spend the time learning CSS instead of tables for layouts. It is no more difficult to learn and understand and you will be much happier you did when you need to make changes. Just my suggestion because someone will always say this when you post a question about using tables as a layout.
Great.  So i my assumption that everytime i work with rows and colums that i need to nest a second within it to make sure that a particular row or column doesn't expand with others?
wow.  ok.  so i guess i should learn CSS, huh?
ASKER CERTIFIED SOLUTION
Avatar of rbudj
rbudj
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks