👀 Live Preview
Compare normal wrapping vs white-space: nowrap in a narrow container:
Normal wrap
This text wraps when the container is narrow.
nowrap (CSS)
This text stays on one line without breaking.

The <nobr> tag controls line breaks within text. This guide explains its purpose, deprecated status, and the modern CSS techniques beginners should use instead.
Keep phrases on a single line.
Why HTML5 removed nobr.
Wrap text in opening and closing tags.
CSS replacement for nobr.
Prevent breaks vs suggest breaks.
Avoid overflow on narrow screens.
<nobr> Tag?The <nobr> tag, short for “no break”, is an HTML element used to prevent line breaks within a specific section of text. It instructs the browser to render the enclosed text without wrapping it to the next line, keeping it as a single continuous unit.
The <nobr> tag is deprecated and not recommended for modern web development. Use white-space: nowrap in CSS for the same effect with semantic, maintainable markup.
Learn nobr to read legacy HTML. For phone numbers, brand names, and code snippets that must stay together, apply a CSS class with white-space: nowrap instead.
As of HTML5, the <nobr> tag has been deprecated and is not recommended for use in modern web development practices. While it may still render in some browsers for backward compatibility, its usage is discouraged in favor of more semantic and flexible CSS alternatives.
white-space: nowrap instead.To implement the <nobr> tag, enclose the desired text within opening and closing tags (usage is now discouraged):
<nobr>Your Text Here</nobr><nobr> and closing </nobr> tags.<p>.class="nobr-text" with white-space: nowrap.| Topic | Code Snippet | Notes |
|---|---|---|
| Legacy nobr | <nobr>text</nobr> | Deprecated |
| CSS nowrap | white-space: nowrap; | Recommended |
| HTML class | class="nobr-text" | Semantic markup |
| Optional break | <wbr> | Opposite of nobr |
| Attributes | None | — |
| Browser support | Legacy render | Obsolete tag |
<nobr> vs white-space: nowrap| Approach | Syntax | Status |
|---|---|---|
<nobr> | <nobr>Stay on one line</nobr> | Deprecated |
| CSS nowrap | .nobr-text { white-space: nowrap; } | Valid HTML5 + CSS |
<wbr> | Suggests optional break point | Valid HTML5 |
| Normal wrap | Default browser behavior | Responsive default |
The <nobr> tag does not support any attributes in HTML. Use a CSS class on a semantic element instead:
None nobr tagThe nobr element has no tag-specific attributes.
<nobr>text</nobr>class (replacement) ModernApply a class and style with CSS white-space.
class="nobr-text"Global attributes like class and id are not defined on nobr for new projects—use them on standard elements like <span> or <p> instead.
Legacy nobr markup and the recommended CSS white-space: nowrap replacement.
Compare normal wrapping vs white-space: nowrap in a narrow container:
Normal wrap
This text wraps when the container is narrow.
nowrap (CSS)
This text stays on one line without breaking.
The primary use case for <nobr> is to ensure certain portions of text remain on the same line without breaking, particularly where line breaks could disrupt formatting or readability.
Keep a phrase on one line with the legacy nobr element (deprecated—shown for reference only).
white-space: nowrap instead.<p><nobr>This text should not break</nobr> when displayed in a browser window.</p>The white-space CSS property provides a flexible alternative. Set it to nowrap to prevent line breaks within an element’s content.
.nobr-text {
white-space: nowrap;
}<p class="nobr-text">This text will not break</p>Replace <nobr> with these modern techniques:
Set white-space: nowrap on any element to prevent line breaks inside it.
.phone-number,
.brand-name,
.nobr-text {
white-space: nowrap;
}<wbr> — Suggest optional break points (opposite of nobr).overflow-x: auto — Allow horizontal scroll on small screens when nowrap is required.Preventing line breaks affects readability on small screens:
nowrap can cause text to extend beyond the viewport on mobile.Enclose the phrase inside <nobr> opening and closing tags.
The renderer treats the content as a single unbreakable inline run.
Presentation moved to CSS white-space: nowrap.
Apply white-space: nowrap on semantic elements with a class.
Due to its deprecated status, treat <nobr> as legacy-only. Browsers still render it for backward compatibility, but it is obsolete and not part of HTML5.
Major browsers still apply no-wrap behavior to <nobr> on old pages. Do not use it in new projects—use white-space: nowrap instead.
HTML5 separated structure from presentation—line-break control belongs in CSS.
Bottom line: Browsers still render <nobr> for old pages, but it is obsolete. Use CSS white-space: nowrap in all new projects.
While the <nobr> tag served a useful purpose in older versions of HTML, its deprecated status and limited functionality make it unsuitable for modern web development.
By leveraging CSS properties like white-space: nowrap, developers can achieve similar results in a more flexible and maintainable manner.
Given its deprecated status, avoid using the <nobr> tag in new projects. Use modern CSS techniques such as white-space: nowrap to achieve similar results while maintaining semantic HTML markup.
white-space: nowrap via CSS classes<wbr> for optional break points<nobr> in new HTML<nobr>Bookmark these before you control line breaks.
Keeps enclosed text on one line.
BehaviorNot part of HTML5 specification.
StatusTag-specific attributes: none.
Attributeswhite-space: nowrap replacement.
nobr blocks breaks; wbr allows them.
Comparisonnowrap can cause horizontal overflow.
Responsivewhite-space: nowrap on the element or a CSS class.nobr prevents breaks; wbr suggests an optional break point.Skip obsolete nobr. Practice white-space: nowrap in the Try It editor.
6 people found this page helpful