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

Tables on a CSS styled page

Status
Not open for further replies.

jakeyg

Programmer
Mar 2, 2005
517
GB
I've got a CSS controlling my layout while the HTML/ASP controls the content

I'm still using tables to show my tabular data though, think that's still allowed ;-), but while I can set the tables overall width using either the CSS or a "width=" directly, I can't contol the width of the "td"s by either method

is this a feature of CSS controlled pages I didn't read about or have I flamingoed up again ?
 
Can you show us some code because the following seems to work ok for me.

Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<style type="text/css">
table { border:1px solid black; }
td { width:200px; border: 1px solid red;}
</style>
</head>

<body>
<table>
<tr>
<td>blah</td>
<td>blah</td>
<td>blah</td>
</tr>
</table>
</body>
</html>

Foamcow Heavy Industries - Web design and ranting
Buy Languedoc wines in the UK
 
This seems to work but I am not at all sure why you would want to do it:

Code:
<body>
<table>
<tr>
<td><span style="width:200px; overflow:hidden">
blahblahblahblahblahblahblahblahblahblahblahblahblahblah
</span></td>
<td>blah</td>
<td>blah</td>
</tr>
</table>
</body>

Clive
 
I just re-read the original post.
If you set the overall width of the table then perhaps it's true you cannot alter the width of the cells if their total doesn't equal that of the table.
The cells must fill the width of the table after all.
Try sizing all of them except one, this may then adjust to take up the "slack".

Foamcow Heavy Industries - Web design and ranting
Buy Languedoc wines in the UK
 
It's too hard to tell without seeing an example of what might be in the table, but I have some ideas that may help:
[ul]
[li]if the contents of the td are too big for the proposed size, that will make it bigger than you want it. However, I think setting the table-layout property of the table to fixed makes it cut off the part that doesn't fit: CSS fixed-table-layout[/li]
[li]I've been happier with the results when I set the width of the table using some absolute value (like px), then setting the width of the cells to relative values (like %)[/li]
[/ul]

Does this help?

--
-- Ghodmode
 
Shoot me in the head
Found a random "td {width: 700px;}" buried in the CSS
unsurprisingly, when I deleted that it worked fine

sorry for the blonde moment
no more late night coding for me, I'll stick to playing battlefield2 at 3am I think
 
Get the Web Developers Toolbar for Firefox (google for it). Onr of the many useful features it gives you is a tool wheer you click on a bit of your page and it tells you what CSS is being applied to it. It's great for finding errors like that.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top