<nobr>

HTML <nobr> Tag

The <nobr> tag is creates a text with non-breaking lines. It doesn’t allow the text to divide multiple lines automatically. With the <nobr> tag the text is displayed in a single line, and a horizontal scroll bar appears to make it readable.

Usually, if the text goes outside of the screen, the browser automatically break the text to the next line, but the <nobr> tag does not allow to break the line.

The <nobr> is a non-standard element. Although it may still work in some browsers, its use is discouraged since it can be removed at any time. Use the CSS white-space property instead.

Syntax

Syntax

The <nobr> tag comes in pairs. The content is written between the opening (<nobr>) and closing (</nobr>) tags.

Example of the HTML <nobr> tag:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <body>
    <nobr>
     Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
    </nobr>
  </body>
</html>

Result

You can use the CSS white-space property instead of the <nobr> element and achieve the same result.

Example of the CSS white-space property instead of the <nobr> tag:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      p.a {
        white-space: nowrap;
      }
    </style>
  </head>
  <body>
    <h1>Example of using the CSS property white-space</h1>
    <p class="a">
      It is an ordinary and very long text that is very inconvenient to read, as it is written in one line, and you have to scroll horizontally to read it.
    </p>
  </body>
</html>

Attributes

Attributes

The <nobr> tag supports the Global Attributes and the Event Attributes.

How to style <nobr> tag? Common properties to alter the visual weight/emphasis/size of text in <nobr> tag:

CSS font-style property sets the style of the font. normal | italic | oblique | initial | inherit. CSS font-family property specifies a prioritized list of one or more font family names and/or generic family names for the selected element. CSS font-size property sets the size of the font. CSS font-weight property defines whether the font should be bold or thick. CSS text-transform property controls text case and capitalization. CSS text-decoration property specifies the decoration added to text, and is a shorthand property for text-decoration-line, text-decoration-color, text-decoration-style.

Coloring text in <nobr> tag:

CSS color property describes the color of the text content and text decorations. CSS background-color property sets the background color of an element.

Text layout styles for <nobr> tag:

CSS text-indent property specifies the indentation of the first line in a text block. CSS text-overflow property specifies how overflowed content that is not displayed should be signalled to the user. CSS white-space property specifies how white-space inside an element is handled. CSS word-break property specifies where the lines should be broken.

Other properties worth looking at for <nobr> tag:

CSS text-shadow property adds shadow to text. CSS text-align-last property sets the alignment of the last line of the text. CSS line-height property specifies the height of a line. CSS letter-spacing property defines the spaces between letters/characters in a text. CSS word-spacing property sets the spacing between words.



请遵守《互联网环境法规》文明发言,欢迎讨论问题
扫码反馈

扫一扫,反馈当前页面

咨询反馈
扫码关注
返回顶部