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!

CSS and fixed width tables

Status
Not open for further replies.

jamesdrake

IS-IT--Management
Apr 21, 2003
1
US
I have a cell in a table that is being fed by an ADODB connection. The recordset that drops the info into the cell sometimes consists of twenty or thirty pieces of data.

When this amount of data is dropped into the cell, the table extends far to the right of the screen (appropriate behaviour for default tables). I want the table to stay fixed at 600 pixels and wrap the data to a new line without breaking the words...

any suggestions?
 
You can add width=&quot;600&quot; to the <TD> tag. This will give you 600 pixels minimum. However - be aware that if there is no whitespace (spaces, tabs, newlines) in the data, it will continue to push the width of the cell beyond the 600 pixels.

There is a way to handle that, but it is not as easy or straight forward.

Good luck

Einstein47
(&quot;Vision without action is a daydream - Action without vision is a nightmare. Japanese Proverb&quot;)
 
You can use CSS to solve this problem:

Leave your table without any extra attributes, i.e.:
Code:
<table>
   ...Table Data...
</table>
[code]

Add this line in the [code]body
section of your HTML page:
Code:
<style>
table{
width: 600px;
}
</style>

This is an inline stylesheet, you can also use a stylesheet in an external file, but I figured this would be easier to start.

This is the &quot;proper&quot; way to format web pages, separating content from presentation. For a great tutorial and reference on CSS (and other W3C technologies), check out
Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top