wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes TD Width Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "TD Width" Watch "TD Width" New topic
Author

TD Width

Shiaber Shaam
Ranch Hand

Joined: Jun 16, 2006
Posts: 252
Hi,

I have a data which is so long and i want to fix the width of the td. I am not able to do it. The table width gets increased based on the data. Please give a solution to fix the table/td width irrespective of the data.

Thanks in advance ...
[ July 09, 2008: Message edited by: Shiaber Shaam ]

$Hi/\bEr
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61612
    
  67

Set the width using CSS.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Shiaber Shaam
Ranch Hand

Joined: Jun 16, 2006
Posts: 252
I tried like style="width:20pc".
Can you please provide a sample.

Thanks,
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61612
    
  67

And what happened? Perhaps you could provide some actual code?
Shiaber Shaam
Ranch Hand

Joined: Jun 16, 2006
Posts: 252
Hi,

<bean:write name="problem"/>

If i disable the above statement, the table looks fine. If i enable the above statement, the whole table goes pathetic as the data is too long. I am struggling to fix it.

Please help.

Thanks,
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61612
    
  67

As that is Struts statement it's not very useful in this forum.

What you should do is to compare the generated HTML before and after to see what the differences are.
Shiaber Shaam
Ranch Hand

Joined: Jun 16, 2006
Posts: 252
<html>
<head>
<style>


.myNewStyle {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight: bold;
color: #FF0000;
}

.my2ndNewStyle {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight: bold;
color: #FF0000;
}

.my3rdNewStyle {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight: bold;
font-size: 20pt;
color: #FF0000;
}
</style>

</head>
<body>
<p class="my3rdNewStyle">My CSS styled text</p>
<table border=2 width="100%">
<tr>
<td colspan=5 style="text-align:center">Test</td>
<tr>
<td style="width:5pc">a</td>
<td style="width:5pc"> </td>
<td style="width:5pc"> </td>
<td style="width:5pc">yuauullllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllyuauullllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllyuauullllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllyuauulllllllllllllllllllllllllllllllllllllllllllllllllll lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllyuauullllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllvvvyuauullllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllyuauulllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll lllllllllllyuauullllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllyuauullllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllyuauullllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllyuauulllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllyuauullllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllyuauullllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllyuauullllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllyu auullllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllyuauullllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllyuauullllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllyuauullllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllyuauullllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllyuauullllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllyuauullllllllllllll</td>
<td>Not tied to a fixed width except due to tables width set.</td>
</tr>
<tr>
<td>a</td>
<td> </td>
<td> </td>
<td> </td>
<td>You don't have to do the width for every row.</td>
</tr>
</table></body></html>

This is a sample block similar to mine.
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321



use px instead of pc OR use % sign to set width.


Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
Shiaber Shaam
Ranch Hand

Joined: Jun 16, 2006
Posts: 252
Hi,

I have tried those possibilities. Even then, i couldn't fix it.


Thanks,
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61612
    
  67

Well, yeah. If there are no breaks in the text, the cell will stretch to accommodate the text. Is that the actual data? If not, please don't waste our time with nonsense. What's the actual data that's causing the issue?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61612
    
  67

And if the real data turns out to not be breakable, was is the result you seek? Wrapping? Clipping?
Shiaber Shaam
Ranch Hand

Joined: Jun 16, 2006
Posts: 252
Hi,

I am not here to waste our folks' time.
This is the test data in our application.
I just wanted to know whether its possible to wrap this text by fixing the td width.
I have spent more than 5 hours in fixing it and found the data which creates the problem.

Please help me.

Thanks,
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61612
    
  67

No. The table tag will not wrap data without breaks (like spaces). If you want the datra to break, you'll need to add spaces to it where you want it to break. If you want long data to clip, you can investigate the clip CSS property.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: TD Width