[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 176
  • Last Modified:

Writing to HTML page

An *.HTML Page does not seem to recognise newline and return characters '\r\n' I'm using to write to it but a *.txt file can recognise these characters and show all the text I'm writing to it in different lines. I want to write to an html file but the new line characters are not being recognised, thus text is shown as one single long line. what to i do to make the *.html file recognise new line and return characters?
  • 2
1 Solution
By default, HTML removes extraneous whitespace.

You have a couple of options, you can put all of your content inside a <pre> tag, e.g.  :

            <!-- PUT YOUR CONTENT HERE -->

Or you can translate the newlines into <br/> elements and the extra spaces into &nbsp; elements (&nbsp; = "non-breaking space").
Insert "<br>" (or "<br>\r\n") instead of "\r\n". :-)
Ah, sorry lhankins - I didn't notice your last comment.

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now