Skip to content Skip to sidebar Skip to footer

Why Is A Newline Converted Into A ' ' In Any Given .html File?

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: Foo: Bar

Solution 1:

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.

Post a Comment for "Why Is A Newline Converted Into A ' ' In Any Given .html File?"