用'\\\<br/>`在html中换行 [英] Line break in html with `\n`
本文介绍了用'\\\<br/>`在html中换行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我觉得我问的问题非常小问题)有没有办法使html正确对待 \\\
换行符?或者我必须用
< br />
?
I feel like i'm asking very noob question) Is there way to make html properly treat \n
line breaks? Or i have to replace them with <br/>
?
https://jsfiddle.net/zawyatzt/
推荐答案
这是为了在html中显示新行并返回回车,那么你不需要明确地执行它。您可以通过设置空白属性的预行值来在css中执行此操作。
This is to show new line and return carriage in html, then you don't need to do it explicitly. You can do it in css by setting the white-space attribute pre-line value.
<span style="white-space: pre-line">@Model.CommentText</span>
这篇关于用'\\\<br/>`在html中换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文