HTML <nobr> Tag

The <nobr> element tried to keep its text on a single line — the browser would not wrap at spaces inside it, which can force horizontal scrolling.

Learn it only to recognize legacy pages. For every new project, use CSS white-space: nowrap on a <span> (or other element) instead.

Deprecated / Non-standard.

Do not use <nobr> in new HTML. It was never standard HTML. Prefer white-space: nowrap.

CSS replacement.

<span class="nobreak">…</span> with .nobreak { white-space: nowrap; } is the clear, conforming approach.

HTML Syntax

syntax.html
<nobr> text</nobr>

Both tags were used historically. Modern equivalent: <span style="…"> is fine for demos; prefer a class + white-space: nowrap in real stylesheets.

Attributes

<nobr> has no element-specific attributes. Prefer CSS instead of the tag:

Attribute / approachDescriptionTry it
(none specific)Legacy tag only — no tag-only attributesTry it
class + CSSCorrect today — white-space: nowrap on a classTry it
<wbr>Opposite idea: mark a preferred break opportunity inside long textTry it

Global Attributes

The <nobr> tag also supports the Global Attributes in HTML (legacy recognition only — do not ship new markup).

Live Preview

Toggle white-space: nowrap (the modern replacement) inside a narrow box.

Narrow box (about 12rem). Compare wrapping vs CSS nowrap — not the obsolete <nobr> tag.

Preview

This phrase stays readable when wrapping is allowed, or forces one long line with nowrap.

white-space: normal

HTML Examples

Short, copy-ready snippets. Prefer the CSS examples. Use Try It Yourself for a live editor.

Example 1 — Legacy <nobr> (Study Only)

Historical markup. Prefer CSS in new work even if a browser still renders this.

HTML
<!-- Deprecated / non-standard — do not use in new pages -->
<p>
  <nobr>This long phrase should stay on one line.</nobr>
</p>
Try It Yourself

How It Works

  1. Wrap the phrase in <nobr>…</nobr> (legacy only).
  2. Browser intent: avoid wrapping at spaces inside the element.
  3. Side effect: narrow viewports may need horizontal scroll.
  4. Replace with CSS when you update the page.

Example 2 — CSS white-space: nowrap

The recommended replacement for <nobr>.

HTML
<p class="nobreak">
  This long phrase should stay on one line.
</p>

<!-- In CSS: .nobreak { white-space: nowrap; } -->
Try It Yourself

How It Works

  1. Keep semantic HTML (a <p> or <span>).
  2. Add a class such as nobreak.
  3. Set white-space: nowrap in CSS.
  4. Test overflow on small screens before shipping.

Example 3 — Prefer Breaks with <wbr>

When text is long but may wrap, mark a soft break — the opposite of forbidding wraps.

HTML
<p>
  https://example.com/docs/<wbr>guides/<wbr>html/nobr
</p>
Try It Yourself

How It Works

  1. Do not use nobr when you want controlled wrapping.
  2. Insert <wbr> where a break is acceptable.
  3. Browser wraps there only if the line would otherwise overflow.
  4. Pair with CSS (overflow-wrap, etc.) when URLs or codes still spill.

Edge Cases & Pitfalls

standards

Never standard HTML

Wide support does not make <nobr> conforming. Validators flag it; use CSS.

mobile

Horizontal overflow

Long nowrap phrases can break layouts on phones. Reserve nowrap for short strings.

a11y

Zoom and reflow

Users who enlarge text need wrapping. Forced one-line text can become hard to read.

contrast

nobr vs wbr

One forbids breaks; the other suggests them. Pick based on whether wrapping helps.

nbsp

&nbsp; is different

A non-breaking space glues two words. nowrap keeps a whole run on one line.

pre

Preformatted text

For code blocks, prefer <pre> / white-space variants over nobr.

Browser Support

The <nobr> element is non-standard / deprecated HTML. It is not recommended for authors and is not a Node.js, Deno, or Bun API.

✓ Deprecated · Use CSS

<nobr>

Never standard HTML. Many browsers still render it for legacy pages, but authors should use white-space: nowrap instead.

0% Authoring use (new pages)
Google Chrome Legacy render
Deprecated
Mozilla Firefox Legacy render
Deprecated
Apple Safari Legacy render
Deprecated
Microsoft Edge Legacy render
Deprecated
Opera Legacy render
Deprecated
Samsung Internet Legacy render
Deprecated
Internet Explorer Legacy
Deprecated
<nobr> Do not use

Bottom line: Recognize it in old documents; ship white-space: nowrap for new UI. Prefer wbr when soft breaks help.

Key Takeaways

  • Fact: <nobr> is deprecated and was never standard HTML.
  • Replace: white-space: nowrap on a normal element.
  • Contrast: use <wbr> when a soft break is better than no break.
  • Practice: avoid forcing long one-line text on mobile.

One line: skip <nobr> — use CSS white-space: nowrap when you truly need a single line.

Default CSS Settings

Engines that still recognize <nobr> typically treat it like nowrap text. Approximate idea:

default.css
/* legacy mapping idea — do not rely on the tag */
nobr {
  white-space: nowrap;
}

/* preferred author CSS */
.nobreak {
  white-space: nowrap;
}

Author with the class form so your HTML stays standard even if the UA rule for nobr changes.

Frequently Asked Questions

nobr kept its text on one line so the browser would not wrap at spaces. Users might need to scroll horizontally to read long phrases.
No. It was never standard HTML and is deprecated / obsolete. Do not use it in new pages.
Use CSS white-space: nowrap on a span or other element. That is the MDN-recommended replacement.
nobr tried to forbid wrapping. wbr marks a preferred opportunity to break a long word or string when needed.
Many engines still render it for legacy pages, but that is not a reason to use it. Prefer CSS so your markup stays conforming.
Yes. Long nowrap text can force horizontal overflow. Use it sparingly (short labels, codes) and test narrow viewports.

Next: noembed

Continue with the HTML noembed tag tutorial.

noembed tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful