<pre>
Labels can define pre-formatted text. Surrounded by the<pre>
label
text in the element is usually reserved spaces and line breaks. The text will also be rendered in a monospaced font. Often used to represent computer source code.
Let's look at an example first:
as shown in the figure, in the pre
label, all spaces and line breaks are displayed according to the original format. In the div
label, it is what we are familiar with. Spaces and line breaks are invalid. To change lines, you must use <br/>
labels.
If we use the back-end string method, store it in the database, and then find out and display it to the front-end, or directly pass the string from the back-end to the front-end for display, if we want to wrap, directly at the place where the string needs to be wrapped Just add \n
(note that it is not /n
) .
Note: The characters are included \n
in the database and stored in the database, and you can't see \n
the words in the query , but copy the corresponding character string and paste it into the notepad to open it, there will be a line break effect. For the convenience of the diagram, I modified the corresponding string literal directly in the database and added it manually \n
. The effect is \n
that it will be displayed on the front end . In the above figure, I was also worried about \
the escaping of symbols , and I added two \
symbols to the database .