HTML not reading %0A

44,023

Different encoding. %0A is URL-encoding of a newline, which you would use in (obviously) URLs. &x0a; would be the HTML-encoding of the same character that you would use in HTML, but it doesn't work, for a variety of reasons. To break a line in HTML, you can use <br> tag.

EDIT:

the problem wit a <br /> tag is that all i want is simply a new line. <br /> creates WAY too much white space

No, it doesn't:

foo<br>
bar

Share:
44,023
Admin
Author by

Admin

Updated on September 14, 2022

Comments

  • Admin
    Admin over 1 year

    I have this code:

    elf='%0A';
    document.getElementById('writebox').innerHTML=("hello there"+elf+"friend");
    

    When the function that this is inside is called, the text that appears in the div is not a line break, but rather just "%0a". This confuses me, because inside another different function, elf works fine. Any ideas why?

    • Admin
      Admin almost 9 years
      Inside ordinary HTML the linefeed is ignored by the browser - use <br> instead. Why it may work in another area is that the html element could be either a textarea or a pre tag
  • Admin
    Admin almost 9 years
    the problem wit a <br /> tag is that all i want is simply a new line. <br /> creates WAY too much white space.
  • War10ck
    War10ck almost 9 years
    @Mr.Chameleon In that case, style the <br /> tag with CSS to make it appear like you'd like it to