HTML <nobr> Tag

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 2 Examples
Legacy HTML

What You’ll Learn

The <nobr> tag controls line breaks within text. This guide explains its purpose, deprecated status, and the modern CSS techniques beginners should use instead.

01

No-Break Text

Keep phrases on a single line.

02

Deprecated Status

Why HTML5 removed nobr.

03

Syntax

Wrap text in opening and closing tags.

04

white-space: nowrap

CSS replacement for nobr.

05

nobr vs wbr

Prevent breaks vs suggest breaks.

06

Responsive Tips

Avoid overflow on narrow screens.

What Is the <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.

⚠️
Deprecated in HTML5 — Use CSS

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.

🚫 Deprecated Status

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.

  • Non-standard element, never part of the official HTML5 specification.
  • Browsers may still apply no-wrap behavior on legacy pages.
  • New projects should use white-space: nowrap instead.

📝 Syntax

To implement the <nobr> tag, enclose the desired text within opening and closing tags (usage is now discouraged):

syntax.html
<nobr>Your Text Here</nobr>

Syntax Rules

  • Requires both opening <nobr> and closing </nobr> tags.
  • Can wrap inline text inside block elements like <p>.
  • Does not accept any tag-specific attributes.
  • Modern replacement: class="nobr-text" with white-space: nowrap.

⚡ Quick Reference

TopicCode SnippetNotes
Legacy nobr<nobr>text</nobr>Deprecated
CSS nowrapwhite-space: nowrap;Recommended
HTML classclass="nobr-text"Semantic markup
Optional break<wbr>Opposite of nobr
AttributesNone
Browser supportLegacy renderObsolete tag

⚖️ <nobr> vs white-space: nowrap

ApproachSyntaxStatus
<nobr><nobr>Stay on one line</nobr>Deprecated
CSS nowrap.nobr-text { white-space: nowrap; }Valid HTML5 + CSS
<wbr>Suggests optional break pointValid HTML5
Normal wrapDefault browser behaviorResponsive default

🧰 Attributes

The <nobr> tag does not support any attributes in HTML. Use a CSS class on a semantic element instead:

None nobr tag

The nobr element has no tag-specific attributes.

<nobr>text</nobr>
class (replacement) Modern

Apply 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.

Examples Gallery

Legacy nobr markup and the recommended CSS white-space: nowrap replacement.

👀 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.

📚 Common Use Cases

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.

Preventing Line Breaks

Keep a phrase on one line with the legacy nobr element (deprecated—shown for reference only).

⚠️ Deprecated tag — use CSS white-space: nowrap instead.
nobr-example.html
<p><nobr>This text should not break</nobr> when displayed in a browser window.</p>
Try It Yourself

CSS Property: white-space

The white-space CSS property provides a flexible alternative. Set it to nowrap to prevent line breaks within an element’s content.

index.css
.nobr-text {
  white-space: nowrap;
}
index.html
<p class="nobr-text">This text will not break</p>
Try It Yourself

🔄 Alternatives

Replace <nobr> with these modern techniques:

CSS Property: white-space

Set white-space: nowrap on any element to prevent line breaks inside it.

nowrap-alternative.css
.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.
  • Responsive design — Allow wrapping on mobile unless a break truly breaks meaning.

♿ Accessibility

Preventing line breaks affects readability on small screens:

  • Horizontal overflownowrap can cause text to extend beyond the viewport on mobile.
  • Zoom users — Large text may not wrap, making content harder to read.
  • Use sparingly — Only prevent breaks for short phrases (dates, codes, brand names).
  • Test on mobile — Verify nowrap text does not break your layout at 320px width.

🧠 How <nobr> Works

1

Author wraps text

Enclose the phrase inside <nobr> opening and closing tags.

Markup
2

Browser skips wrapping

The renderer treats the content as a single unbreakable inline run.

Rendering
3

HTML5 deprecated nobr

Presentation moved to CSS white-space: nowrap.

Evolution
=

Today: use CSS nowrap

Apply white-space: nowrap on semantic elements with a class.

Browser Support

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.

Obsolete · Use CSS nowrap

Legacy rendering only

Major browsers still apply no-wrap behavior to <nobr> on old pages. Do not use it in new projects—use white-space: nowrap instead.

95% Legacy rendering
Google Chrome Legacy render · Obsolete
Legacy render
Mozilla Firefox Legacy render · Obsolete
Legacy render
Apple Safari Legacy render · Obsolete
Legacy render
Microsoft Edge Legacy render · Obsolete
Legacy render
Internet Explorer Supported · EOL
Legacy render
Opera Legacy render · Obsolete
Legacy render

Why nobr was removed

HTML5 separated structure from presentation—line-break control belongs in CSS.

📝
white-space: nowrap Flexible, reusable styling via CSS classes
Replacement
📱
Responsive design CSS media queries can allow wrapping on small screens
Mobile
<nobr> tag 95% legacy rendering

Bottom line: Browsers still render <nobr> for old pages, but it is obsolete. Use CSS white-space: nowrap in all new projects.

Conclusion

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.

💡 Best Practices

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.

✅ Do

  • Use white-space: nowrap via CSS classes
  • Apply nowrap only to short, meaningful phrases
  • Test layout on narrow mobile viewports
  • Use <wbr> for optional break points

❌ Don’t

  • Use <nobr> in new HTML
  • Prevent wrapping on long paragraphs
  • Ignore horizontal overflow on mobile
  • Mix nobr with responsive flex layouts blindly

Key Takeaways

Knowledge Unlocked

Six truths every developer should know about <nobr>

Bookmark these before you control line breaks.

6
Core concepts
🚫 02

Deprecated

Not part of HTML5 specification.

Status
⚙️ 03

No Attributes

Tag-specific attributes: none.

Attributes
🎨 04

CSS nowrap

white-space: nowrap replacement.

Alternative
↔️ 05

vs wbr

nobr blocks breaks; wbr allows them.

Comparison
📱 06

Mobile caution

nowrap can cause horizontal overflow.

Responsive

❓ Frequently Asked Questions

It prevents line breaks within enclosed text, keeping it on a single line.
No. It is deprecated. Browsers may render it on legacy pages, but do not use it in new HTML.
Use white-space: nowrap on the element or a CSS class.
No. The nobr tag does not support any attributes in HTML.
nobr prevents breaks; wbr suggests an optional break point.

Control Line Breaks with CSS

Skip obsolete nobr. Practice white-space: nowrap in the Try It editor.

Try CSS nowrap →

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.

6 people found this page helpful