Why doesn't javascript newlines work inside html?

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

So I have the following:


  
    
  
<         


        
13条回答
  •  太阳男子
    2020-12-06 12:47

    The document object represents an HTML document; any text written to the document will be processed by the browser's HTML renderer. In HTML, all adjacent whitespace, including line breaks (e.g., "\n"), are collapsed into a single space when rendered. This is why you need
    , which is rendered as a line break. You can make \n work by replacing it with
    or by writing into a

     element:

    Hello
    World

提交回复
热议问题