Google Answers Logo
View Question
 
Q: CSS style that preserves indents and line breaks while allowing word wrapping? ( No Answer,   3 Comments )
Question  
Subject: CSS style that preserves indents and line breaks while allowing word wrapping?
Category: Computers > Programming
Asked by: mxnmatch-ga
List Price: $5.00
Posted: 25 Oct 2002 12:26 PDT
Expires: 01 Nov 2002 16:47 PST
Question ID: 89831
If I use the PRE tag in HTML, it leaves everything as I typed it. It
keeps indentations and line breaks but doesn't do any word wrapping.
Is there any way (perhaps using a SPAN tag with a css style) to
preserve indents and line breaks while allowing word wrapping? For
instance, I might write a paragraph that would wrap across lots of
lines, then I would hit enter twice to leave a blank line, then I
would hit space twice to indent some text then type something then hit
enter twice again and then type another paragraph. With PRE it would
make both paragraphs stay all on one line. Without any tags it would
put everything into one large paragraph that's wrapped without any
line breaks or indents. Of course I could just use the BR tag and nbsp
to accomplish those things, but I was hoping that there was a css
style that would make it easy for me to do things quickly in any text
editor or web page input box (like I would use in a blogger or a
message board) without needing to spend so much time adding in the
formatting tags. (I want to do this when using an html editor is too
cumbersome or just inconvenient, so please don't tell me to just use
an html editor like homesite or dreamweaver.)
Answer  
There is no answer at this time.

Comments  
Subject: Re: CSS style that preserves indents and line breaks while allowing word wrapping?
From: alldaykettle-ga on 29 Oct 2002 21:16 PST
 
How about the following:

<style>
p.ww
{
 word-wrap: break-word;width:88%;left:0>
}
</style>
<body>
<PRE>
<P class=ww>Paste a paragraph of text here that failed to wrap in your
old pages when within pre tags</P>
</PRE>
...
Now, after you confirm that the paragraph is wrapping, you can view
the source and type some spaces smack in the middle of the paragraph.
Resave, Refresh, and see if those spaces are rendered as pre contents
should. You can also play with the width, making it 50%, 100% or
whatever you like.

I have to thank you for asking this question. I was wondering about
this very same thing for a long time, but couldn't find the answer
until I saw you ask it! I don't know what machine or browser you're
using, but the above test worked for me in Internet Explorer, version
5.5. Hope it works for you.

Cheers
Dave
Subject: Re: CSS style that preserves indents and line breaks while allowing word wrapping?
From: alldaykettle-ga on 29 Oct 2002 21:26 PST
 
Sorry about the 'left:0>'.
You can remove that from the style line that begins with 'word-wrap'
Subject: Re: CSS style that preserves indents and line breaks while allowing word wrappin
From: dylans-ga on 30 Oct 2002 10:51 PST
 
CSS 3 adds a proposed wrap-option, but this is not yet a standard:
http://www.w3.org/TR/2002/WD-css3-text-20021024/#wrap-option-prop

IE5.5 and higher has the proprietary word-wrap as the previous poster
mentioned, but this is not supported in other browsers.

-Dylan

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy