This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Preserve word wrap and line breaks Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Preserve word wrap and line breaks" Watch "Preserve word wrap and line breaks" New topic
Author

Preserve word wrap and line breaks

Tom Wake
Greenhorn

Joined: Feb 10, 2008
Posts: 5
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

Joined: Feb 10, 2008
Posts: 5
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

Joined: Jan 10, 2002
Posts: 61103
    
  66

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

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 ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Tom Wake
Greenhorn

Joined: Feb 10, 2008
Posts: 5
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
Replace the breaks in the database with the <br/> tag.

Eric
Tom Wake
Greenhorn

Joined: Feb 10, 2008
Posts: 5
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

Joined: Jan 28, 2008
Posts: 43
Sure: how about:



'HTH


Christophe Porteneuve aka TDD
"They did not know it was impossible, so they did it." --Mark Twain
Pragmatic Guide to JavaScript: http://books.pragprog.com/titles/pg_js/
Prototype and script.aculo.us: http://books.pragprog.com/titles/cppsu/
Tom Wake
Greenhorn

Joined: Feb 10, 2008
Posts: 5
Thanks very much will give this a try
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Preserve word wrap and line breaks