Why is a newline converted into a ' ' in any given .html file?

前端 未结 1 390
遇见更好的自我
遇见更好的自我 2021-01-29 08:32

I have a question related to HTML. In order to demonstrate my simple question, I will use a minimal example.

Consider the following HTML content:



        
1条回答
  •  后悔当初
    2021-01-29 08:34

    In HTML a carriage return or line feed in the source code is treated as white space and rendered as a space. Multiple spaces or white space (CR, LF, tabs, etc.) amount to a single white space on the rendered page.

    So if you have 50 carriage returns in your source code between Foo and : Bar it will render a one space (Foo : Bar) when th HTML page is displayed in the browser.

    From the HTML 4.01 spec: Controlling line breaks.

    0 讨论(0)
提交回复
热议问题