HTML <nobr> Tag

The <nobr> element prevents the text it contains from automatically wrapping across multiple lines. Since all text is displayed in a single line, a horizontal scroll bar appears.

This tag was used with the <wbr> tag which specifies where in a text it would add a line-break. Unlike the <br> tag, the <wbr> tag makes a line break only when the current line has already extended beyond the browser's display window margins.

Example

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.

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

Attributes

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

Result

Browser support