新行没有< br>标签 [英] new line without <br> tag
问题描述
写下这个html:
lorem ipsum
lorem ipsum
lorem ipsum
浏览器显示:
lorem ipsumlorem ipsumlorem ipsum
有没有办法看到这个:
lorem ipsum
lorem ipsum
lorem ipsum
而不使用< br>
标签,并且不使用textarea。
我需要这个,因为我的文字有100.000个短行,而且要写< br>
标签100.000次是耗时的。
您可以使用 < pre>
标记以保持换行符
< pre>
lorem ipsum
lorem ipsum
lorem ipsum
< / pre>
pre
标签的默认样式为等宽字体字体,但可以被覆盖。
您可以使用 white-space:pre
CSS属性。
< div style =white-space:pre>
lorem ipsum
lorem ipsum
lorem ipsum
< / div>
white-space
,但您应该参阅文档以选择最合适的一个。
请注意, pre
会将每一个换行符都对待,包括< pre>
或< div>
标签。如果你不想要他们,你需要做:
< div style = ...> lorem ipsum
lorem ipsum
...
Writing this html:
lorem ipsum
lorem ipsum
lorem ipsum
browser shows:
lorem ipsumlorem ipsumlorem ipsum
Is there a way to see this:
lorem ipsum
lorem ipsum
lorem ipsum
without using <br>
tag at the end of each line, and without using textarea.
I need this because I have a text with 100.000 short lines, and it is time consuming to write <br>
tag 100.000 times.
You can use the <pre>
tag to keep the line breaks.
<pre>
lorem ipsum
lorem ipsum
lorem ipsum
</pre>
The default style for pre
tags is monospaced font, but that can be overriden.
You can achieve the same effect without any extra default formatting using the white-space: pre
CSS property.
<div style="white-space: pre">
lorem ipsum
lorem ipsum
lorem ipsum
</div>
There are several other values for white-space
, but you should refer to the documentation to choose the most fitting one.
Note that pre
will treat every line break the same including the one following the <pre>
or <div>
tags. If you don't want them you will need to do:
<div style=...>lorem ipsum
lorem ipsum
...
这篇关于新行没有< br>标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!