Welcome to Dream.In.Code
Getting Help is Easy!

Join 132,611 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 917 people online right now. Registration is fast and FREE... Join Now!




Word wrap within a table

 
Reply to this topicStart new topic

Word wrap within a table, I don't want overflow!

Redian
post 12 Jul, 2008 - 02:18 PM
Post #1


New D.I.C Head

*
Joined: 28 Dec, 2007
Posts: 22

Hey,
I'm working on a new website and currently just writing the HTML that the user info will fit into. However, the table has a width of 600 pixels, and if the user goes past this, the table would expand (weird). So I set the table-layout to fixed. Good, but now in firefox the text overflows rather than wrapping around and onto the next line. Aside from hiding what falls outside, is there anyway to correct this?
User is offlineProfile CardPM

Go to the top of the page

Martyr2
post 12 Jul, 2008 - 02:33 PM
Post #2


Programming Theoretician

Group Icon
Joined: 18 Apr, 2007
Posts: 5,062



Thanked 175 times

Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions


Ok I am going to assume you mean cells that have something like a picture or wording with no spaces that under normal conditions would stretch the cell of a table or under the "fixed" layout would overflow the cell onto other cells etc.

Firefox is following standards with this and IE is the one that is not. IE clips the content automatically while FireFox lets it overflow. So to correct that on the table cell that is overflowing, you can specify a style of "overflow: hidden" which will clip the context of the cell so that it won't stretch, but will clip anything that overflows the cell boundaries.

Below is a simple example....

CODE

<table border="1" cellpadding="0" cellspacing="0" width="500" style="table-layout: fixed;">
<tr>
<td width="200" style="overflow: hidden;"& #62;Nowhereisatablecellthathasnospacesandshouldstretchunderflexibleconditionsand
clipunderfixed.</td>
<td width="300">Here is some content that should wrap around in the individual cell.</td>
</tr>
</table>


With this sample if the table was not "fixed" the first cell would expand to the length of the sentence without spaces. But since it is declared as "fixed" we can use the overflow "hidden" to clip the sentence so that it will not overflow the cell of 200 pixels in width.

Hopefully that is what you are asking about and that this solves your problem.

Edit: Oh and just to make sure you know, this works the same in both IE and FF. Overflow is a standard CSS both browser support.

"At DIC we be cell clipping code ninjas... we also clip people at the knees so that we leave them begging for mercy" decap.gif

This post has been edited by Martyr2: 12 Jul, 2008 - 02:35 PM
User is offlineProfile CardPM

Go to the top of the page

Redian
post 12 Jul, 2008 - 02:48 PM
Post #3


New D.I.C Head

*
Joined: 28 Dec, 2007
Posts: 22

That's what I don't want. Sorry, anime2.gif I guess I wasn't clear enough. Just like if this line were to go on forever in this section of the website, the table doesn't expand, and it doesn't overflow, I want there to be returns placed into the text so that it all fits within the table, on multiple lines. I've never had this problem before so I don't know what to do.
User is offlineProfile CardPM

Go to the top of the page

Martyr2
post 12 Jul, 2008 - 03:56 PM
Post #4


Programming Theoretician

Group Icon
Joined: 18 Apr, 2007
Posts: 5,062



Thanked 175 times

Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions


Ok then, if you take out the table layout as "fixed", give your cells each their own width then any text will wrap. Now if the text doesn't have spaces, like in my example where it is all one string of characters, it will expand. Now if you don't want it to expand in this case you are going to have to break the string using a server-side language.

Lines of content with no spaces are not going to be forceably broken from a display point of view. You will have to script in the breaks yourself. Checking for words that have greater than some number and insert your break in the middle of the string.

Otherwise text with spaces in it will wrap normally to whatever the cell width is. This is default behavior.

If I am still missing the point, perhaps you can display a screenshot of what you are talking about?

Thanks. smile.gif
User is offlineProfile CardPM

Go to the top of the page

Redian
post 12 Jul, 2008 - 05:16 PM
Post #5


New D.I.C Head

*
Joined: 28 Dec, 2007
Posts: 22

No, perfect! Thank you. That was exactly it. I didn't realize that it was because it was all one word that that happened. I was just using & quot;Yadayadayadayadayadayadayadayadayadayadayadayadayadayadayadayadayadayadayad
ayadayadayadayadayadayadayadayada" to test it. That was really silly of me

Thank you!
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 02:34AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month