Skip to content

`<nobr>` - No Line Break (Deprecated)

Deprecated Non-standard

The <nobr> element was a non-standard HTML element that prevented line breaks within its content. Text wrapped in <nobr> tags would not wrap to the next line, even if it exceeded the width of its container.

This is how <nobr> was used in the past:

Result

The <nobr> element was deprecated for several important reasons:

Never Standardized: Unlike most HTML elements, <nobr> was never part of any W3C or WHATWG specification. It was a proprietary extension that some browsers implemented inconsistently.

CSS Does It Better: The CSS white-space property provides a standardized, more flexible way to control text wrapping behavior with better browser support and maintainability.

Semantic Issues: <nobr> mixed presentation with content structure, violating the principle of separation of concerns that modern web development embraces.

Limited Control: Unlike CSS, <nobr> offered no fine-grained control over text behavior in different contexts or screen sizes.

The standard replacement for <nobr> is the CSS white-space property:

Result

This approach provides the same functionality as <nobr> but with better browser support and standards compliance.

For more nuanced control over text breaking behavior:

Result

Using &nbsp; for Specific Non-Breaking Spaces

Section titled “Using &nbsp; for Specific Non-Breaking Spaces”

For preventing breaks at specific points, use non-breaking space entities:

Result

The <wbr> element lets you suggest where breaks are allowed in long text:

Result

There are legitimate cases where preventing line breaks improves readability:

Numeric Values with Units: Keep numbers with their units (100 km, $50 USD, 5 GB)

Proper Names: Company names, product names, or titles that should stay together

Code Snippets: Short inline code that shouldn’t break mid-identifier

Date and Time: Keep date/time components together (Jan 15, 2024)

Mathematical Expressions: Simple equations or formulas (E = mc²)

Phone Numbers: Keep area codes with numbers

Result

If you’re maintaining legacy code that uses <nobr>, here’s how to migrate:

<p>
Price: <nobr>$99.99 USD</nobr>
</p>
<div>
<nobr>This entire section should not wrap</nobr>
</div>

Step 1: Identify all <nobr> elements in your codebase using search or grep.

Step 2: Create a CSS class for non-wrapping text:

.no-wrap {
white-space: nowrap;
}

Step 3: Replace <nobr> tags with <span class="no-wrap">:

<!-- Before -->
<nobr>text</nobr>
<!-- After -->
<span class="no-wrap">text</span>

Step 4: For block-level elements, apply the class directly:

<!-- Before -->
<div><nobr>content</nobr></div>
<!-- After -->
<div class="no-wrap">content</div>

Step 5: Test thoroughly, especially on narrow viewports and mobile devices.

The <nobr> element was never standardized, but had varying support:

BrowserSupport PeriodNotes
Internet Explorer3.0 - 11Implemented as proprietary extension
Netscape2.0 - 4.xEarly implementation
FirefoxRemovedDeprecated, use CSS instead
ChromeRemovedDeprecated, use CSS instead
SafariRemovedDeprecated, use CSS instead
EdgeNever supportedModern browsers only

Suggests an optional line break opportunity within text. Learn more →

The <nobr> element was never part of any official HTML specification:

Not in WHATWG HTML Living Standard: The element is not recognized in the current HTML standard.

Not in W3C HTML5: Never included in any W3C HTML specification.

Historical Reference: Mentioned in historical browser documentation as a proprietary extension.

Modern Equivalent: CSS white-space: nowrap property (CSS Text Module Level 3)