Jump to content

Archived

This topic is now archived and is closed to further replies.

kharbat

For HTML experts

Recommended Posts

Hi there,

I am using javascript that writes an output text into a table. The tables consists of several rows and several columns.

The output text length is not fixed.. each time could have a different length.

the table keeps resizing cells width according to the length of the text, so the table's view becomes in consistent. is there anyway to have a table with a fixed size or width for cells?

makes sense??

Share this post


Link to post
Share on other sites
<table width=[number of pixels]>
<tr><td width=[number of pixels]></td></tr>
</table>

Share this post


Link to post
Share on other sites
try to use style sheet
[code]
<table style="width:100px;">
<tr><td>text</td></tr>
<table>
[/code]
You'll need the px in the style sheet.

Share this post


Link to post
Share on other sites
i just tried style sheet.. table keeps resizing width.. any other suggestions?

Share this post


Link to post
Share on other sites
How about letting us see the online version of the output that isn't working the way you want it to work. That might make closing in on a solution less of a guessing game.

Share this post


Link to post
Share on other sites
lol.. sure.. i will put a code below.. Try editing it with frontpage or some editior..

try to type something that exceeds cells width.. the table will resize width of the cells, so they become inconsistent.. all what i want is to know if there is a way to let cells width remain fixed when some long text entered the text get orgnized in lines rather than resizing cells..

any help is really appreciated

[code]
<table border="1" width="300" id="table1">
    <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
    </tr>
</table>
[/code]

Share this post


Link to post
Share on other sites
As long as there are breaks (spaces) in the text, it will wrap around and not extend the width of the table cells beyond what you have specified.

On the other hand if you have text like thisisaverylongandboringsillystatementdesigned to breaktablesbecauseIthinkIcanhavefunwithstufflikethis ... then the table will expand as it has no clue where (or why) to break the text.

At least that's how my browser works.

Share this post


Link to post
Share on other sites
yeah i think that too.. in fact the output text is a file name that might be long and continuous sometimes like this

WindowsVistaBeta2ISOBuild5384432bitx86(www.fulldls.com).torrent

and i guess that there is no way to deal with this problem..

Thanks alot for your time anyway.. and i really appreciate your help

Share this post


Link to post
Share on other sites
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]i guess that there is no way to deal with this problem..[/quote]
Not with plain html. But if you're using javascript there ought to be string handling functions that let you break long strings into shorter strings. One obvious problem is that some visitor may decide to change the font size and all your pixel-precision goes out the window then.

Perhaps you need to rethink the format of your presentation to cope with the overly long filenames (or words).

Share this post


Link to post
Share on other sites
I couldnt do this but I know that there is a way to do it but what if you where to create a PHP script that will count the number of letters in the variebles and add a <br /> tag when a certain number of letters are present. And if it is manually inputed text it could do the same thing...

I know it could be done. Maybe some one here would want to do it...

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.