By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,314 Members | 1,775 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,314 IT Pros & Developers. It's quick & easy.

Not possible to maintain 100% width.....

P: n/a
Here is my HTML table formatting code.

<table border="1" width="100%">

<tr width = "100%">

<td
width="33%">11asdhagdshaskgashjgahjgadhjgdjshdgasj dgajdgadjhgdgahjdgadhjsgad
hagdahjga</td>

<td
width="33%">11asdhagdshaskgashjgahjgadhjgdjshdgasj dgajdgadjhgdgahjdgadhjsgad
hagdahjga</td>

<td
width="34%">11asdhagdshaskgashjgahjgadhjgdjshdgasj dgajdgadjhgdgahjdgadhjsgad
hagdahjga</td>

</tr>

</table>

Even though I have set 100% width for the table data, table cell data is not
getting truncating to the width specified.

I am presuming it is because of no blank space in the above text.

How to make it word wrap so that irrespective of the cell data cell will
maintain the specified width.

Please advice.

John


Nov 18 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
You're right about the lack of spaces. That is indeed what is causing it. As
for a solution, you have a couple of choices:

1. Make sure that you break your strings if necessary with spaces.
2. Modify all browsers to do this for you.

I don't think number 2 is doable.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"John Smith" <JJ*****@hotmail.com> wrote in message
news:uS**************@TK2MSFTNGP11.phx.gbl...
Here is my HTML table formatting code.

<table border="1" width="100%">

<tr width = "100%">

<td
width="33%">11asdhagdshaskgashjgahjgadhjgdjshdgasj dgajdgadjhgdgahjdgadhjsgad hagdahjga</td>

<td
width="33%">11asdhagdshaskgashjgahjgadhjgdjshdgasj dgajdgadjhgdgahjdgadhjsgad hagdahjga</td>

<td
width="34%">11asdhagdshaskgashjgahjgadhjgdjshdgasj dgajdgadjhgdgahjdgadhjsgad hagdahjga</td>

</tr>

</table>

Even though I have set 100% width for the table data, table cell data is not getting truncating to the width specified.

I am presuming it is because of no blank space in the above text.

How to make it word wrap so that irrespective of the cell data cell will
maintain the specified width.

Please advice.

John

Nov 18 '05 #2

P: n/a
It can get really ugly, as you cannot do relative formatting, but you can also define a hard number of pixels that the cell should be sized. Try <td width="250"> in place of <td width="33%"> to force the cell to a width of 250 pixels. Whether it wraps or just cuts off I am not sure.

"John Smith" wrote:
Here is my HTML table formatting code.

<table border="1" width="100%">

<tr width = "100%">

<td
width="33%">11asdhagdshaskgashjgahjgadhjgdjshdgasj dgajdgadjhgdgahjdgadhjsgad
hagdahjga</td>

<td
width="33%">11asdhagdshaskgashjgahjgadhjgdjshdgasj dgajdgadjhgdgahjdgadhjsgad
hagdahjga</td>

<td
width="34%">11asdhagdshaskgashjgahjgadhjgdjshdgasj dgajdgadjhgdgahjdgadhjsgad
hagdahjga</td>

</tr>

</table>

Even though I have set 100% width for the table data, table cell data is not
getting truncating to the width specified.

I am presuming it is because of no blank space in the above text.

How to make it word wrap so that irrespective of the cell data cell will
maintain the specified width.

Please advice.

John


Nov 18 '05 #3

P: n/a
OK.
I think I will go for option 1 !!!

Is there any in built function in .NET which does the work of spltting the
string.
Thanks
John
"Kevin Spencer" <ks******@takempis.com> wrote in message
news:#s**************@TK2MSFTNGP09.phx.gbl...
You're right about the lack of spaces. That is indeed what is causing it. As for a solution, you have a couple of choices:

1. Make sure that you break your strings if necessary with spaces.
2. Modify all browsers to do this for you.

I don't think number 2 is doable.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"John Smith" <JJ*****@hotmail.com> wrote in message
news:uS**************@TK2MSFTNGP11.phx.gbl...
Here is my HTML table formatting code.

<table border="1" width="100%">

<tr width = "100%">

<td

width="33%">11asdhagdshaskgashjgahjgadhjgdjshdgasj dgajdgadjhgdgahjdgadhjsgad
hagdahjga</td>

<td

width="33%">11asdhagdshaskgashjgahjgadhjgdjshdgasj dgajdgadjhgdgahjdgadhjsgad
hagdahjga</td>

<td

width="34%">11asdhagdshaskgashjgahjgadhjgdjshdgasj dgajdgadjhgdgahjdgadhjsgad
hagdahjga</td>

</tr>

</table>

Even though I have set 100% width for the table data, table cell data is

not
getting truncating to the width specified.

I am presuming it is because of no blank space in the above text.

How to make it word wrap so that irrespective of the cell data cell will
maintain the specified width.

Please advice.

John


Nov 18 '05 #4

P: n/a
Hi John,
Is there any in built function in .NET which does the work of spltting the
string.
Not if I understand you correctly. There are many string manipulation
functions, but it sounds like you're assuming that there can be a single
solution for many situations. For example, what are your rules for splitting
the string? You've set your table cells to 33%, and your table to 100%. The
first question is, with diffferent screen resolutions, and different
browsers, what exactly does "33%" come to in pixels (answer: it varies quite
a lot!). The second question is, how many pixels wide is a character? The
answer is, unless you're using a fixed-width/fixed-size font, it varies
quite a lot! Okay, but let's say that the user is using a fixed-width table
cell. It should be relatively easy to figure out how many pixels there are,
and you can use some of the .Net classes for figuring out the width of a
given character of a given font. So, why isn't there a method to which you
can pass the width of the table cell and get the stiring split? Well, what
happens if the cell width is less than a single character? The string would
have to be split into an infinite number of sub-strings in that case. The
third question is, what would you consider a good rule for WHERE to split a
long spaceless string? Of course, there is no answer to that one, as it
depends largely on what the string IS, and what it isa being used for.

Long story short, you need to develop your own solution to this. You can
certainly split the string yourself on the server, but only you know what
business rules you need to employ in doing it.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"John Smith" <JJ*****@hotmail.com> wrote in message
news:#z**************@TK2MSFTNGP10.phx.gbl... OK.
I think I will go for option 1 !!!

Is there any in built function in .NET which does the work of spltting the
string.
Thanks
John
"Kevin Spencer" <ks******@takempis.com> wrote in message
news:#s**************@TK2MSFTNGP09.phx.gbl...
You're right about the lack of spaces. That is indeed what is causing it.
As
for a solution, you have a couple of choices:

1. Make sure that you break your strings if necessary with spaces.
2. Modify all browsers to do this for you.

I don't think number 2 is doable.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"John Smith" <JJ*****@hotmail.com> wrote in message
news:uS**************@TK2MSFTNGP11.phx.gbl...
Here is my HTML table formatting code.

<table border="1" width="100%">

<tr width = "100%">

<td

width="33%">11asdhagdshaskgashjgahjgadhjgdjshdgasj dgajdgadjhgdgahjdgadhjsgad
hagdahjga</td>

<td

width="33%">11asdhagdshaskgashjgahjgadhjgdjshdgasj dgajdgadjhgdgahjdgadhjsgad
hagdahjga</td>

<td

width="34%">11asdhagdshaskgashjgahjgadhjgdjshdgasj dgajdgadjhgdgahjdgadhjsgad
hagdahjga</td>

</tr>

</table>

Even though I have set 100% width for the table data, table cell data is
not
getting truncating to the width specified.

I am presuming it is because of no blank space in the above text.

How to make it word wrap so that irrespective of the cell data cell

will maintain the specified width.

Please advice.

John



Nov 18 '05 #5

P: n/a
Hi John,

The following solution may seem a little ugly and will increase the amount of data in a table sent to the client by 2, but it may still be suitable in your situation. Add a space after each character and apply a negative letter-spacing style (you may need to adjust your letter-spacing based on a font size used):

<table border="1" width="100%" ID="Table2" style="LETTER-SPACING: -2px">
<tr width="100%">
<td width="33%">1 1 a s d h a g d s h a s k g a s h j g a h j g a d h j g d j s h d g a s j d g a j d g a d j h g d g a h j d g a d h j s g a d h a g d a h j g a</td>
<td width="33%">1 1 a s d h a g d s h a s k g a s h j g a h j g a d h j g d j s h d g a s j d g a j d g a d j h g d g a h j d g a d h j s g a d h a g d a h j g a</td>
<td width="34%">1 1 a s d h a g d s h a s k g a s h j g a h j g a d h j g d j s h d g a s j d g a j d g a d j h g d g a h j d g a d h j s g a d h a g d a h j g a</td>
</tr>
</table>
If this trade-off is not exceptable in your case I would examine the browser's resolution and set the table width to a sertain value (using server-side code) instead of 100% and would leave the percantage in cell.

Regards,

Svetlana

"John Smith" wrote:
Here is my HTML table formatting code.

<table border="1" width="100%">

<tr width = "100%">

<td
width="33%">11asdhagdshaskgashjgahjgadhjgdjshdgasj dgajdgadjhgdgahjdgadhjsgad
hagdahjga</td>

<td
width="33%">11asdhagdshaskgashjgahjgadhjgdjshdgasj dgajdgadjhgdgahjdgadhjsgad
hagdahjga</td>

<td
width="34%">11asdhagdshaskgashjgahjgadhjgdjshdgasj dgajdgadjhgdgahjdgadhjsgad
hagdahjga</td>

</tr>

</table>

Even though I have set 100% width for the table data, table cell data is not
getting truncating to the width specified.

I am presuming it is because of no blank space in the above text.

How to make it word wrap so that irrespective of the cell data cell will
maintain the specified width.

Please advice.

John


Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.