Html <br> 是否有任何 ASCII 字符?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33909888/
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
Is there any ASCII character for <br>?
提问by Antony SUTHAKAR J
Typically we all using HTML numbers or names in web pages. For example, &
is &
or &
, and $
, @
, ?
, ?
, etc.
通常我们都在网页中使用 HTML 数字或名称。例如,&
是&
或&
,和$
,@
,?
,?
,等。
Is there an HTML number or name for <br>
?.
是否有 ? 的 HTML 编号或名称<br>
。
回答by Amadan
&
is a character; &
is a HTML character entity for that character.
&
是一个字符;&
是该字符的 HTML 字符实体。
<br>
is an element. Elements don't get character entities.
<br>
是一个元素。元素不会获得角色实体。
In contrast to many answers here, \n
or
are not equivalent to <br>
. The former denotes a line break in text documents. The latter is intended to denote a line break in HTML documents and is doing that by virtue of its default CSS:
与这里的许多答案相反,\n
或
不等同于<br>
. 前者表示文本文档中的换行符。后者旨在表示 HTML 文档中的换行符,并且是通过其默认 CSS 来实现的:
br:before { content: "\A"; white-space: pre-line }
A textual line break can be rendered as an HTML line break or can be treated as whitespace, depending on the CSS white-space
property.
文本换行符可以呈现为 HTML 换行符或可以视为空格,具体取决于 CSSwhite-space
属性。
回答by Rob Avery
You may be looking for the special HTML character,
.
您可能正在寻找特殊的 HTML 字符
.
You can use this to get a line break, and it can be inserted immediately following the last character in the current line. One place this is especially useful is if you want to include multiple lines in a list within a title or alt
label.
您可以使用它来获取换行符,并且可以在当前行的最后一个字符之后立即插入它。如果您想在标题或alt
标签内的列表中包含多行,这是特别有用的一个地方。
回答by ketan
回答by Amit
No, there isn't.
不,没有。
<br>
is an HTML ELEMENT. It can't be replaced by a text node or part of a text node.
<br>
是一个HTML 元素。它不能被文本节点或文本节点的一部分替换。
You cancreate a new-line effect using CR/LF inside a <pre>
element like below:
您可以在<pre>
元素内使用 CR/LF 创建换行效果,如下所示:
<pre>Line 1
Line 2</pre>
But this is not the same as a <br>
.
但这与<br>
.
回答by Bhojendra Rauniyar
In HTML, the <br/>
tag breaks the line. So, there's no sense to use an ASCII character for it.
在 HTML 中,<br/>
标签会断行。因此,为它使用 ASCII 字符是没有意义的。
In CSS we can use \A
for line break:
在 CSS 中,我们可以使用\A
换行符:
.selector::after{
content: '\A';
}
But if you want to display <br>
in the HTML as text then you can use:
但是如果你想<br>
在 HTML 中显示为文本,那么你可以使用:
<br> // < denotes to < sign and > denotes to > sign
回答by Max Kozlov
The answer is amp#13; — change "amp" to the ampersand sign and go.
答案是amp#13;— 将“amp”更改为&符号并开始。