HTML <nobr> Tag

The <nobr> tag is used to create a text with non breaking lines. It prevents the text to automatically divide multiple lines. 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

The <nobr> tag comes in pairs; the closing tag (</nobr>) is required.

Example

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <body>
    <nobr>
      This 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.  
    </nobr>
  </body>
</html>

Result

Let’s take an example where we will use CSS property white-space instead of the <nobr> element.

Example

<!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">
      This 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>

Result

Attributes

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

Browser support