HTML <nobr> Element
The <nobr> element was a non-standard HTML element used to prevent text and other inline content from automatically wrapping onto a new line. Content enclosed by the element remained on a single line unless an explicit line-breaking opportunity was provided.
<nobr> element must not be used in new HTML. Use the CSS white-space: nowrap; property when content needs to remain on a single line.
Historical Syntax
Older webpages may contain markup similar to the following:
<nobr>This entire line of text will remain together without automatically wrapping.</nobr>
When the available space became narrower than the content, a supporting browser kept the enclosed text on one line rather than wrapping it normally. This could cause the content to extend beyond its container and create horizontal scrolling. This code is shown for historical reference only and should not be used in modern HTML.
Attributes
The <nobr> element did not have any standardized element-specific attributes. Its historical behavior came from the element itself, which instructed supporting browsers not to automatically wrap its contents.
Historical Use
The <nobr> element was useful when an author wanted a particular phrase, label, number, or other piece of content to remain together on a single line. It was sometimes used for navigation labels, product information, prices, dates, or other short pieces of text that could become confusing when divided across two lines.
Authors also used <nobr> to control the appearance of page layouts before CSS provided reliable control over whitespace and line wrapping. However, applying it to long sections of text could easily make a page wider than the visitor's browser window.
The element was often associated with the <wbr> element, which could provide a preferred location where a long non-wrapping sequence was allowed to break when necessary.
Why It Became Obsolete
The <nobr> element controlled presentation rather than describing the structure or meaning of its content. It was also a non-standard browser extension rather than a normal HTML element.
CSS provides direct control over whitespace and line wrapping without requiring special presentational markup. The same general effect can be created with white-space: nowrap;, while additional CSS can determine how overflowing content should be handled.
Separating this behavior from the HTML also makes it easier to change or remove the non-wrapping behavior for different screen sizes, an important consideration for responsive webpages.
Modern Alternative
Use an ordinary HTML element with the CSS white-space property when text should remain on a single line:
<p class="no-wrap">This entire line of text will remain together without automatically wrapping.</p>
.no-wrap {
white-space: nowrap;
}
Unlike the obsolete element, CSS allows the non-wrapping behavior to be applied only where it is needed and changed for different layouts or screen sizes.
If a long word, URL, or other sequence normally should remain together but needs an optional place where the browser may break the line, the modern <wbr> element can provide a line-breaking opportunity.
Legacy Browser Support
The <nobr> element is obsolete and non-standard, but modern browsers may continue to recognize its historical non-wrapping behavior for compatibility with older webpages. This legacy browser support does not make the element valid for use in modern HTML.
Existing <nobr> elements should be replaced with ordinary HTML and the CSS white-space: nowrap; declaration when older webpages are updated.
For detailed legacy browser compatibility information, see Can I Use: HTML <nobr> Element .
Related Elements
The modern <wbr> element provides an optional line-breaking opportunity within text. The <br> element creates a required line break, while CSS should be used when automatic text wrapping needs to be controlled.
Specifications
The <nobr> element is listed as an entirely obsolete, non-conforming feature in the WHATWG HTML Living Standard . Authors should use CSS to control line wrapping instead.
