I came across an interesting problem today. I have a text email I\'m sending from a Web page. I\'m displaying a preview and wanted to put the preview in a fixed font retai
Just replace all your hard line breaks with <br/>
and put the text into a div
with the desired width. You can do the same with spaces: Replace them with
.
Be sure you do this after you escape the special characters into HTML, otherwise the
are not interpreted but printed on the page.
Try
selector {
word-wrap: break-word; /* IE>=5.5 */
white-space: pre; /* IE>=6 */
white-space: -moz-pre-wrap; /* For Fx<=2 */
white-space: pre-wrap; /* Fx>3, Opera>8, Safari>3*/
}
create a <pre></pre>
tag or use something like
<p style="width:800px">
....
</p>
with fixed width, i think text are wrapped
Try replacing any double spaces with
- which should work to make your look of double spaces come through.
Crack all those new line and hard enters out with <br />
.
Style the text output to make it look like a fixed-width with the font-family:
font-family:monospace;
You may need to size it up properly, something smaller than the surrounding text, but that will give you the look of a PRE, and what a plain text email will look like.
Put it all in a DIV with a fixed with and that could be worth a look.
Maybe you could use a RichTextEditor (such as FreeTextBox) to display the text.
Set the editor's font to Courier, disable/hide the toolbars, ...