• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Preserve word wrap and line breaks

 
Tom Wake
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I don't know if anyone here can help me on this one,

Basically I've got a page reading in text from a database.

Now there are problems that I've been encountering with white space.
I've made a section in my CSS to combat this problem which is now fine in firefox. Internet Explorer seems to be the problem.

putting in -
word-wrap: break-word; preserves line breaks in the text being read in, however this option doesn't wrap the text to the cell it's being put in.

white-space: normal; wraps the text to the cell but doesn't preserve line breaks.

I can only seem to use one of these options at a time so I'm abit stuck for ideas really. Does anyone know anything about this or a fix for it?

Thanks!
[ February 10, 2008: Message edited by: Bear Bibeault ]
 
Tom Wake
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh I was just wondering why this had been edited? I'm new here and hope I'm complying with your rules.

Hope someone can help me!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It'd be helpful if you could provide a code snippet that clearly shows the issues. Make it the smallest snippet that exhibits the problem and be sure to use UBB code tags to preserve formatting (read this for more information).

With regards to editing, your subject line was probably adjusted. I usually do this when it's excessively long, contains all uppercase, isn't clear or on topic, or has excessive punctuation.

You might also want to include the text snippet you're trying to display.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tom,
Welcome to Javaranch.

Other than our naming policy and our most important rule (Be Nice) there really aren't any rules that you could have broken.
I may have been that the moderator who edited your post saw a way to tweak your question to improve its chances of being answered.

We've compiled a page of tips, here.

Good luck with your question.

-Ben


[clunk]
[ February 10, 2008: Message edited by: Ben Souther ]
 
Tom Wake
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

Thank you for your quick responses.

Basically my CSS class is -



The code that reads in from the database is -


The pre codes in the class are fine for firefox and include line breaks in the text being read in and wrap the text within the cell.

The break-all is for IE, break word includes line breaks but doesn't wrap the text. If I use break-word it wraps the text within the cell but doesn't include line breaks.

Also, using <pre> </pre> tags intead of my css class doesn't seem to wrap the text in either browser.

Any ideas?
[ February 11, 2008: Message edited by: Tom Wake ]
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Replace the breaks in the database with the <br/> tag.

Eric
 
Tom Wake
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Eric,

Thanks for the suggestion. I have the problem that users of the website are able to submit News articles to the database and I'm sure that not everyone will remember to use code in their articles.

Is there a way to automatically convert line breaks to the html code?
 
Christophe Porteneuve
Author
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure: how about:



'HTH
 
Tom Wake
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks very much will give this a try
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic