Suggests an optional line break opportunity within text. Learn more →
<nobr> ElementThe <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:
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:
This approach provides the same functionality as <nobr> but with better browser support and standards compliance.
For more nuanced control over text breaking behavior:
For preventing breaks at specific points, use non-breaking space entities:
<wbr> for Suggesting Break PointsThe <wbr> element lets you suggest where breaks are allowed in long text:
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
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><style> .nowrap { white-space: nowrap; }</style>
<p> Price: <span class="nowrap">$99.99 USD</span></p>
<div class="nowrap"> This entire section should not wrap</div><!-- Using a utility CSS framework like Tailwind --><p> Price: <span class="whitespace-nowrap">$99.99 USD</span></p>
<div class="whitespace-nowrap"> This entire section should not wrap</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:
| Browser | Support Period | Notes |
|---|---|---|
| Internet Explorer | 3.0 - 11 | Implemented as proprietary extension |
| Netscape | 2.0 - 4.x | Early implementation |
| Firefox | Removed | Deprecated, use CSS instead |
| Chrome | Removed | Deprecated, use CSS instead |
| Safari | Removed | Deprecated, use CSS instead |
| Edge | Never supported | Modern browsers only |
Suggests an optional line break opportunity within text. Learn more →
Forces a line break at a specific point. 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)