用于单行换行的 html 代码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3856304/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
html code for single-line line break
提问by tintincutes
i would like to show this text in my html code:
我想在我的 html 代码中显示此文本:
<html>
Name 1
Name 2
Managers
</html>
I tried to do this but then in the site it shows like this:
我试图这样做,但随后在网站上显示如下:
Name 1 Name 2 Managers.
姓名 1 姓名 2 经理。
If I put <p>
on it, it will show like this:
如果我穿上<p>
它,它会显示如下:
<html>
<p>Name 1 </p>
<p> Name 2 </p>
<p> Managers </p>
The result is this:
结果是这样的:
Name 1
姓名 1
Name 2
姓名 2
Managers
经理
Is there any code how to keep this single like?
是否有任何代码如何保持这种单一状态?
Thanks
谢谢
回答by RedFilter
回答by Robusto
In addition to the <br/>
, as others have pointed out, you can also enclose text content in the <pre></pre>
tag, which will preserve all the whitespace.
除了<br/>
,正如其他人指出的那样,您还可以将文本内容包含在<pre></pre>
标签中,这将保留所有空白。
回答by sshow
Use a line break <br>
使用换行符 <br>
<html>
Name 1<br>
Name 2<br>
Managers
</html>
From W3Schools.com:
In HTML the
<br>
tag has no end tag.
In XHTML the<br>
tag must be properly closed, like this:<br />
.
在 HTML 中,
<br>
标签没有结束标签。
在XHTML中<br>
标签必须正确关闭,这样的:<br />
。
回答by davecoulter
Try this:
尝试这个:
<html>
Name 1<br />
Name 2<br />
Managers<br />
</html>