HighDots Forums  

How to display non-HTML line breaks

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss How to display non-HTML line breaks in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Samuel Murray
 
Posts: n/a

Default How to display non-HTML line breaks - 09-03-2008 , 02:57 AM






G'day everyone

I'm trying to find out if there is a way (perhaps using CSS) to let
this code:

<table><tr><td>One
Two
Three</td></tr></table>

display the same as if the code would have been:

<table><tr><td>One<br>
Two<br>
Three</td></tr></table>

Of course, once I figure out how to do this, I still have to see if my
wysiwig HTML viewer can display it :-) because my wysiwig HTML viewer
is MS Word and/or OOo Writer. The reason is that I'm trying to use
HTML as an intermediary format to convert CSV to a word processing
format. But let me worry about that... it would be great if any of
you could just help me with the problem described above.

Thanks in advance
Samuel (aka leuce) ltns

Reply With Quote
  #2  
Old   
Ben C
 
Posts: n/a

Default Re: How to display non-HTML line breaks - 09-03-2008 , 03:06 AM






On 2008-09-03, Samuel Murray <leuce (AT) absamail (DOT) co.za> wrote:
Quote:
G'day everyone

I'm trying to find out if there is a way (perhaps using CSS) to let
this code:

table><tr><td>One
Two
Three</td></tr></table

display the same as if the code would have been:

table><tr><td>One<br
Two<br
Three</td></tr></table
td { white-space: pre-wrap }

or just white-space: pre (not all browsers support all the more exotic
flavours of white-space).


Reply With Quote
  #3  
Old   
Neredbojias
 
Posts: n/a

Default Re: How to display non-HTML line breaks - 09-03-2008 , 03:15 AM



On 02 Sep 2008, Samuel Murray <leuce (AT) absamail (DOT) co.za> wrote:

Quote:
G'day everyone

I'm trying to find out if there is a way (perhaps using CSS) to let
this code:

table><tr><td>One
Two
Three</td></tr></table

display the same as if the code would have been:

table><tr><td>One<br
Two<br
Three</td></tr></table

Of course, once I figure out how to do this, I still have to see if my
wysiwig HTML viewer can display it :-) because my wysiwig HTML viewer
is MS Word and/or OOo Writer. The reason is that I'm trying to use
HTML as an intermediary format to convert CSV to a word processing
format. But let me worry about that... it would be great if any of
you could just help me with the problem described above.
Look into the html <pre> attribute.

--
Neredbojias
http://www.neredbojias.org/ http://www.neredbojias.net/
Great Sights and Sounds
http://adult.neredbojias.org/ http://adult.neredbojias.net/ (adult)


Reply With Quote
  #4  
Old   
Nico Schuyt
 
Posts: n/a

Default Re: How to display non-HTML line breaks - 09-03-2008 , 03:20 AM



Samuel Murray wrote:

Quote:
I'm trying to find out if there is a way (perhaps using CSS) to let
this code:

table><tr><td>One
Two
Three</td></tr></table

display the same as if the code would have been:

table><tr><td>One<br
Two<br
Three</td></tr></table

Of course, once I figure out how to do this, I still have to see if my
wysiwig HTML viewer can display it :-) because my wysiwig HTML viewer
is MS Word and/or OOo Writer. The reason is that I'm trying to use
HTML as an intermediary format to convert CSV to a word processing
format. But let me worry about that... it would be great if any of
you could just help me with the problem described above.
<table><tr><td><pre>One
Two
Three
1
2
3</pre></td></tr></table>

--
Nico





Reply With Quote
  #5  
Old   
Samuel Murray
 
Posts: n/a

Default Re: How to display non-HTML line breaks - 09-03-2008 , 05:30 AM



On Sep 3, 9:06*am, Ben C <spams... (AT) spam (DOT) eggs> wrote:

Quote:
On 2008-09-03, Samuel Murray <le... (AT) absamail (DOT) co.za> wrote:

I'm trying to find out if there is a way (perhaps using CSS) to let
this code:

td { white-space: pre-wrap }

or just white-space: pre (not all browsers support all the more exotic
flavours of white-space).
Thanks, this really helps.

Incidently, MS Word XP understands pre but not pre-wrap. OOo Writer
2.4 does not understand either of them.

Samuel (leuce)


Reply With Quote
  #6  
Old   
Michael Wojcik
 
Posts: n/a

Default Re: How to display non-HTML line breaks - 09-03-2008 , 01:02 PM



Neredbojias wrote:
Quote:
On 02 Sep 2008, Samuel Murray <leuce (AT) absamail (DOT) co.za> wrote:

I'm trying to find out if there is a way (perhaps using CSS) to let
this code:

table><tr><td>One
Two
Three</td></tr></table

display the same as if the code would have been:

table><tr><td>One<br
Two<br
Three</td></tr></table

Look into the html <pre> attribute.
<PRE> isn't an attribute; it's an element.

A <PRE> block inside the <TD> is not the same as inserting <BR>
elements. Some elements which may be children of <TD> may not be
children of <PRE>. User agents may, and often do, apply formatting
rules to text within a <PRE> block that they don't apply (under the
default styles) to text within <TD>, such as using a monospaced typeface.

In short, this suggestion doesn't do what the OP asked for. Whether it
does what the OP *wants* is another question; and the OP might have
some success using <PRE> plus additional styling to render the text in
a more appropriate manner. (That assumes he doesn't need any of the
elements that <PRE> excludes, such as <IMG>, inline in his <TD>s.)

If Ben's suggestion of "white-space: pre-wrap" won't work, for
example, something like the following might provide the basic feature
with better styling under capable user agents and graceful degredation
under others:

td pre {
font-family: inherit;
white-space: pre-line;
}

<table>
<tr><td><pre>
One
Two
Three
</pre></td></tr>
</table>

"pre-line" seems to me closer to the OP's original request than Ben's
suggestion of "pre-wrap", since the former collapses whitespace.

Obviously the font styling might have to be changed, depending on how
<TD> is styled. "font-family: inherit" works with FF2, but not with
IE7, so "font-family: serif" (or whatever) might be a better choice.

Unfortunately, none of the UAs I tried (FF2, IE7, oOO Writer 2.4)
appear to actually support "white-space: pre-line", so to get this to
render the way I think the OP wants it, you'd have to get rid of the
extra whitespace inside the <PRE> block.

But this combination does preserve the line breaks and it does degrade
gracefully; in particular, oOO Writer will preserve the line breaks,
which I gather the OP wanted. And the line breaks will be preserved
even if CSS is disabled or overridden, which is probably desirable.

--
Michael Wojcik
Micro Focus
Rhetoric & Writing, Michigan State University


Reply With Quote
  #7  
Old   
Ed Mullen
 
Posts: n/a

Default Re: How to display non-HTML line breaks - 09-03-2008 , 01:05 PM



Samuel Murray wrote:
Quote:
G'day everyone

I'm trying to find out if there is a way (perhaps using CSS) to let
this code:

table><tr><td>One
Two
Three</td></tr></table

display the same as if the code would have been:

table><tr><td>One<br
Two<br
Three</td></tr></table

Of course, once I figure out how to do this, I still have to see if my
wysiwig HTML viewer can display it :-) because my wysiwig HTML viewer
is MS Word and/or OOo Writer. The reason is that I'm trying to use
HTML as an intermediary format to convert CSV to a word processing
format. But let me worry about that... it would be great if any of
you could just help me with the problem described above.
I'm confused and curious. Are you only using Word to view HTML or are
you using it to edit/write HTML as well? If the latter, that's just a
terrible idea. I don't know about Open Office but Word generates
hideous HTML.

As for CSV conversion, what's the problem? I can open a .csv file in
Word 2000 directly: It's plain text. Highlight the csv data, click
Table, Convert, Text to Table. Voila.

--
Ed Mullen
http://edmullen.net
A conscience is what hurts when all your other parts feel so good.


Reply With Quote
  #8  
Old   
Ben C
 
Posts: n/a

Default Re: How to display non-HTML line breaks - 09-03-2008 , 01:58 PM



On 2008-09-03, Michael Wojcik <mwojcik (AT) newsguy (DOT) com> wrote:
[...]
Quote:
"pre-line" seems to me closer to the OP's original request than Ben's
suggestion of "pre-wrap", since the former collapses whitespace.
Yes, you're right pre-line is better (or would be if more people
supported it).

Pre-line is the same as normal except that it doesn't collapse newlines,
which is exactly what the OP wants.


Reply With Quote
  #9  
Old   
Bergamot
 
Posts: n/a

Default Re: How to display non-HTML line breaks - 09-03-2008 , 01:59 PM




Michael Wojcik wrote:
Quote:
In short, this suggestion doesn't do what the OP asked for. Whether it
does what the OP *wants* is another question;
It may actually be more a case of deciding on a solution without fully
defining the problem. We don't know the whole situation, just that the
OP has asked how to do these line breaks. It could be doing something
else altogether is a better solution.

--
Berg


Reply With Quote
  #10  
Old   
Bergamot
 
Posts: n/a

Default Re: How to display non-HTML line breaks - 09-03-2008 , 02:02 PM




Ed Mullen wrote:
Quote:
Samuel Murray wrote:

I'm trying to use
HTML as an intermediary format to convert CSV to a word processing
format. But let me worry about that...

I'm confused and curious.
Me, too.

Quote:
As for CSV conversion, what's the problem? I can open a .csv file in
Word 2000 directly
Why the OP wants to use HTML for this is a bit baffling.

--
Berg


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.