Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

table unwanted resizing

Status
Not open for further replies.

mickallen

Technical User
Jan 5, 2001
39
0
0
GB
I have a table with the alignment set to centered.
The sizes of all the table cells and the table its self needs to be kept the same throughout the whole site.
I have set the table height and width to the same on all pages, but as soon as I add content the table resizes. Is there a way to lock the tables size so that the content does not change the size.

P.S the actual table width and height that I set does not change even though the actual size of the tabe has.
 
If you use percentages your cells should stay the same. Also make sure that you set the table width as a percentage such as:

<table width=&quot;75%&quot; height=&quot;40%&quot;>
<tr><td width=&quot;25%&quot; height=&quot;25%&quot;>content here</td></tr>
<tr><td width=&quot;25%&quot; height=&quot;25%&quot;>content here</td></tr>
<tr><td width=&quot;25%&quot; height=&quot;25%&quot;>content here</td></tr>
<tr><td width=&quot;25%&quot; height=&quot;25%&quot;>content here</td></tr></table>

I'm not sure if you were saying that it would be one table with different/dynamic content throughout your site, or not. If not, you shouldn't need the height attribute. If you have some content that won't fit unless the table is bigger, then it WILL automatically stretch the cell(s) larger, so try to pick a size that will hold ALL of your content.

Another benefit of using percentages is that your tables will expand and contract to fit the browser window.

Good Luck! Let me know if it works.
bluDaisy
 
Hello mickallen!

If you want your table cells always be unresizable follow next rules:

1) try to define size of every cell in atlist one row (I usually do it with only first row - it's easier to change sizes later);

2) use percentage to set sizes of your cells and whole table to keep cells' proportion sizes but let table and cells resize as a whole to different screen resolution;

3) use pixels to set sizes if you need your table and cells be always the same size;

4) one more greate tip: if can set size only on some cells (and others to be flexible) and need this cells to keep their sizes in any case - use cell attribute NOWRAP, like this: <td size=&quot;25&quot; nowrap>. In some cases size of such cells can become bigger in browsers (if you have wide table and cells without sizes are not filled with enough amount of text, etc.), but NEVER SMALLER!

Hope it'll help someone sometime...

Good Luck!
 
Hi,
I am facing with same problem.
I tried many ways to fix the table size, but it always fails if the word size is bigger than the width of the cell, it won't automatically wrap the word. I guess wrapping happens at word boundary.
Is there anyway, i can get the content to wrap in a fixed cell size, even if one of the words is bigger than the cell width ? I even tried using tables for each cell to fix the width.
Please let me know in case you know a solution to this or know for sure that a solution does not exist.
Thanks
net
 
To netdost,

if one of the words is bigger then cell width - there is no any possible way to fix cell width :(


 
Arial is a thinner text than most and using it might help with Netdost's problem of words being too long.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top