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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I specify maximum width of table cell 1

Status
Not open for further replies.

spook007

Programmer
May 22, 2002
259
US
I've put together a table on my web site, but I would like to keep the cells at a specified size and not have them expand in width when the info does not fit.

I've tried setting the width, but that only sets the minimum size that the cell can be set at, but it will expand the cell if the contents is larger.
 
Tables can drive you to drink but there is a way! First, make sure that you specify the width of the table in your <TABLE> tag - <TABLE WIDTH=&quot;700&quot;>. Do the same for each table cell - <TD WIDTH=&quot;120&quot;>. These widths are expressed in pixels. This will wrap and text in the individual cells. However, images WILL NOT wrap so if the width of the images is greater than the width of the table cells, it's going to expand your table to fit the images.

Some notes:
1. You can use percentages rather than pixels for the widths of your table and cells. <TABLE WIDTH=&quot;100%&quot;> and <TD WIDTH=&quot;25%&quot;>. These values represent a percentage of available, viewable, SCREEN WIDTH. So, your tables will have different widths for a screen resolution of 800x600 than for a resolution of 1024x768 or 640x480.

2. Don't mix pixels and percentages, ie; <TABLE WIDTH=&quot;100%&quot;> and <TD WIDTH=&quot;100&quot;> will cause you grief.

3. Try to leave one or more cells as 'floaters&quot;, ie; try to keep from speciying the width of all cells - let a couple of them be as wide or narrow as the browser wants them to be.


Hope this helps... There's always a better way...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top