HTML <nobr> 标签用于指示浏览器不要中断指定的文本(例如通常发生在浏览器窗口右边缘的换行)。
这与 <wbr> 标签一起使用,<wbr> 建议扩展浏览器何时可以在其他不可中断的文本序列中插入换行符。与 <br> 标签不同,即使在 <nobr>- 标记的段中也总是会导致换行符,而 <wbr> 标记仅在放置在 <nobr>- 标记的内容段内时才起作用,并且仅当当前行已经超出浏览器的显示窗口边距时才会导致换行符。
不再建议使用此标记,因为它已弃用,在 HTML5 中不受支持。相反,您可以使用 CSS 属性。
语法
<nobr> Statement </nobr>
属性
HTML <nobr> 标签支持 HTML 的 全局属性 。
<nobr> 标签示例
下面的例子将说明nobr标签的用法。在哪里、何时以及如何使用 nobr 标签来继续句子。
No break 语句
考虑以下示例,我们将在句子上使用 <nobr> 标签。
<!DOCTYPE html>
<html>
<head>
<title>HTML nobr Tag</title>
</head>
<body>
<h3>Normal Paragraph</h3>
<p>
This is a very long sequence of text that
is forced to be on a single line, even if
doing so causes the browser
to extend the document window beyond the
size of the viewing pane and the poor user
must scroll right to read the
entire line.
</p>
<h3>No Break Paragraph</h3>
<nobr>
This is a very long sequence of text that
is forced to be on a single line, even if
doing so causes the browser
to extend the document window beyond the
size of the viewing pane and the poor user
must scroll right to read the
entire line.
</nobr>
</body>
</html>
blockquote 中没有中断语句
正如我们所知,blockquote 元素包裹文本并且不允许滚动,当 non breable 句子到达时,它会强行中断句子,但使用 nobr tah 它不起作用。
<!DOCTYPE html>
<html>
<head>
<title>HTML nobr Tag</title>
<style>
blockquote {
width: 200px;
}
</style>
</head>
<body>
<h3>No Break Paragpagh with Blockquote</h3>
<blockquote>
<nobr>
This is a very long sequence of text that
is forced to be on a single line, even if
doing so causes the browser
to extend the document window beyond the
size of the viewing pane and the poor user
must scroll right to read the
entire line.
</nobr>
</blockquote>
<blockquote>
This is a very long sequence of text that
is forced to be on a single line, even if
doing so causes the browser
to extend the document window beyond the
size of the viewing pane and the poor user
must scroll right to read the
entire line.
</blockquote>
</body>
</html>
支持的浏览器
浏览器 | ![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|---|
是否支持 | 1.0 | 12.0 | 1.0 | 4.0 | 15.0 |