Writing to HTML page

Posted on 2004-11-29
Last Modified: 2010-04-01
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?
Question by:VbMonk
    LVL 7

    Accepted 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").
    LVL 3

    Expert Comment

    Insert "<br>" (or "<br>\r\n") instead of "\r\n". :-)
    LVL 3

    Expert Comment

    Ah, sorry lhankins - I didn't notice your last comment.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Title # Comments Views Activity
    servlet init param and contect param 3 46
    maven set up 2 84
    maven webservice example issue 2 61
    instanceof  operator in java 26 54
    Digital marketing agencies have encountered both the opportunities and difficulties that emerge from working with a wide-ranging organizations.
    For Sennheiser, comfort, quality and security are high priority areas. This paper addresses the security of Bluetooth technology and the supplementary security that Sennheiser’s Contact Center and Office (CC&O) headsets provide.  
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now