如何在HTML中不允许在封闭文本中插入换行符?

PHPz
PHPz 转载
2023-09-08 17:01:05 1193浏览

如何在HTML中不允许在封闭文本中插入换行符?

使用 <nobr> 标记可允许 HTML 中的封闭文本不出现中断。 HTML <nobr> 标签用于指示浏览器不要破坏指定的文本。

这与 <wbr> 标签一起使用,<wbr> 会建议扩展浏览器何时可以在不可破坏的序列中插入换行符。文本。与 <br> 标记不同,即使在 <nobr>- 标记的段中,该标记也始终会导致换行,而 <wbr> 标记仅在放置在 <nobr>- 标记的内容段内时才起作用,并且仅当当前行已经超出浏览器的范围时才会导致换行。显示窗口边距。

示例

您可以尝试运行以下代码,以允许 HTML 中的封闭文本不出现中断 -

<!DOCTYPE html>
<html>
   <head>
      <title>HTML nobr Tag</title>
   </head>
   <body>
      <nobr>This is a very long sequence of text that is forced to be
      on a single line, even if doing so causes <wbr />

      the browser to extend the document window beyond the size of the
      viewing pane and the poor user must scroll right <wbr />

      to read the entire line.
      </nobr>
   </body>
</html>

以上就是如何在HTML中不允许在封闭文本中插入换行符?的详细内容,更多请关注php中文网其它相关文章!

声明:本文转载于:tutorialspoint,如有侵犯,请联系admin@php.cn删除