Home > Article > Web Front-end > Example analysis of how to retain spaces and line breaks in html pages
We know that when the browser renders and displays the HTML page, it will process the spaces and newlines in the HTML file, so the formatting we originally wrote in the HTML file may not work. The effect, especially when we want to display structured program code, we will encounter problems, as shown below:
<html> <body> for i = 1 to 10 print i next i </body> </html>
Such HTML files will all be printed when displayed on the browser On one line, it looks like this:
for i = 1 to 10 print i next i
In this way, the understanding of the program cannot be clearly seen, so how can it be displayed as written in the HTML file?
e03b848252eb9375d56be284e690e873The preformatted tag plays its role here. This tag mainly processes spaces and blank lines and retains the spaces and blank lines that exist in the HTML file. . After we add this tag, it looks as follows:
<html> <body> <pre class="brush:php;toolbar:false"> for i = 1 to 10 print i next i