Why doesn't javascript newlines work inside html?

后端 未结 13 2612
梦谈多话
梦谈多话 2020-12-06 12:08

So I have the following:


  
    
  
<         


        
13条回答
  •  鱼传尺愫
    2020-12-06 12:57

    When you write to the page, you're not writing JavaScript; you're writing HTML. \n is a special "line feed" character that doesn't create a line break in the browser's rendering of the HTML. It WILL create a line break in the HTML file itself, but the browser doesn't take this into consideration when it renders out the markup.

    Thus, the br tag is required.

提交回复
热议问题