How to get newline in HTML? Without BR

Y

Yash

In a TD, I would like to print 5 words one below the other. I know I
can use <BR/>. Is there any other way?
I tried
and
This seems to print "\r" and "\n" but not give
the effect of a new line.

I am actually doing this so that I can use the HTML content to export
to an Excel file. A BR introduces new Excel rows which is unwanted for
my requirement.

Thanks,
Yash
 
M

Martin Honnen

Yash said:
In a TD, I would like to print 5 words one below the other. I know I
can use <BR/>. Is there any other way?

Well with HTML you can try the pre element
<td><pre>foo
bar
baz
whatever
whatelse</pre></td>
but I have no idea whether that helps with your Excel problem described
below. And this is comp.lang.javascript, use
comp.infosystems.www.authoring.html for HTML authoring problems.
 
M

Matt Kruse

In a TD, I would like to print 5 words one below the other. I know I
can use <BR/>. Is there any other way?
I tried
and
This seems to print "\r" and "\n" but not give
the effect of a new line.
I am actually doing this so that I can use the HTML content to export
to an Excel file. A BR introduces new Excel rows which is unwanted for
my requirement.

The real fix is a simple CSS rule in your document:

<style>
br {mso-data-placement:same-cell;}
</style>

Now when Excel reads your HTML and finds a <br> tag, it will put a
newline in the same cell rather than spanning rows.

Matt Kruse
 
S

Steve Swift

Yash said:
I am actually doing this so that I can use the HTML content to export
to an Excel file. A BR introduces new Excel rows which is unwanted for
my requirement.

How are you getting from the HTML to the Excel format? I can think of at
least two ways. Whichever way you are doing it, it is wrong for the <BR>
to be interpreted as a new Excel row. It should be interpreted as a
newline inside the Excel cell.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top