JavaScript String blink() Method

Beginner
⏱️ 8 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Deprecated

What You’ll Learn

String.prototype.blink() is a deprecated HTML wrapper method (same API as MDN String.prototype.blink()). It returns a string that wraps your text in a <blink> tag. Learn what it builds, why blinking text was removed, why accessibility standards discourage it, and what to do instead — with five examples and try-it labs.

01

Kind

Instance method

02

Returns

HTML string

03

Status

Deprecated

04

Params

None

05

Mutates?

No

06

Prefer

No blink / a11y

Introduction

Early JavaScript included helpers that wrapped text in HTML presentation tags — blink(), big(), bold(), italics(), and others. They made it easy to inject markup with innerHTML.

Today those wrappers are deprecated. blink() may still return a string for compatibility, but the <blink> element was removed from modern browsers. Blinking text is discouraged for accessibility, and the element is gone.

💡
Learn it, don’t ship it

Study blink() so you can recognize legacy code. For new pages, emphasize text without blinking (color, weight, size) instead of building <blink> strings.

This page is part of JavaScript String Methods. Related topics include big() and bold().

Understanding the blink() Method

Calling str.blink() does not create a live DOM node and does not take arguments. It concatenates an HTML string: <blink> + text + </blink>.

  • It is an instance method on strings (auto-boxed if needed).
  • It returns a new string — the original is unchanged.
  • No parameters — just str.blink().
  • Prefer non-blinking emphasis for real UI.

📝 Syntax

General form of String.prototype.blink:

JavaScript
str.blink()

Parameters

None.

Return value

A string beginning with a <blink> start tag, then the text of str, then a </blink> end tag.

Common patterns

JavaScript
"Hello, world".blink();
// 'Hello, world'

// Prefer static emphasis — do not blink text
const el = document.getElementById("yourElemId");
el.style.fontWeight = "700";

⚡ Quick Reference

GoalCode
Legacy HTML stringstr.blink()
Result shape<blink>...</blink>
Modern emphasisel.style.fontWeight = "700"
Use in new apps?No — deprecated

🔍 At a Glance

Four facts to remember about String.blink().

Returns
string

HTML markup text

Status
deprecated

Compatibility only

Tag
<blink>

Removed from browsers

Replace with
no blink

Accessibility first

📋 blink() vs static emphasis

str.blink()Static CSS emphasis
ResultHTML stringStyled live element (no flash)
Valid HTML today?No (<blink> removed)Yes
Recommended?NoYes
Best forReading legacy codeNew UI / apps

Examples Gallery

Examples follow MDN String.blink() patterns. Use View Output or Try It Yourself for each case.

📚 Getting Started

See the exact HTML string blink() builds.

Example 1 — Basic blink()

MDN-style call that wraps text in <blink>.

JavaScript
const contentString = "Hello, world";
contentString.blink();
// 'Hello, world'
Try It Yourself

How It Works

The method returns markup text only. Nothing is added to the document until you assign it somewhere (for example innerHTML).

Example 2 — Empty String and Special Characters

Tags are still produced for empty text; content is not HTML-escaped.

JavaScript
"".blink();           // ''
"A < B".blink();      // 'A < B'
typeof "x".blink();   // "string"
Try It Yourself

How It Works

Unlike some attribute wrappers, blink() does not escape < inside the text. That is another reason to avoid injecting untrusted strings via innerHTML.

📈 Practical Patterns

Legacy injection patterns and a modern non-blinking replacement.

Example 3 — Injecting with innerHTML (Legacy)

How older demos used the returned string — still produces obsolete markup.

JavaScript
const contentString = "Hello, world";
const html = contentString.blink();
// document.body.innerHTML = html;  // legacy pattern — avoid in new apps

console.log(html);
// Warning:  is not a valid element in modern HTML
Try It Yourself

How It Works

Modern browsers do not blink <blink> content. The element is obsolete, and flashing text is a poor accessibility choice — use static emphasis instead.

Example 4 — Other HTML Wrappers Nearby

Recognize the same pattern family — all deprecated.

JavaScript
"Hi".blink();   // 'Hi'
"Hi".big();     // 'Hi'
"Hi".bold();    // 'Hi'
"Hi".italics(); // 'Hi'
Try It Yourself

How It Works

These helpers share one idea: return presentational HTML strings. Modern code styles elements with CSS (and semantic tags when needed).

Example 5 — Prefer Static Emphasis (No Blink)

MDN advises avoiding blinking elements altogether — emphasize with CSS instead.

JavaScript
const el = document.createElement("p");
el.textContent = "Hello, world";
el.style.fontWeight = "700";
el.style.color = "#b45309";

// document.body.appendChild(el);
console.log(el.style.fontWeight);
console.log(el.outerHTML);
Try It Yourself

How It Works

You get a real element and valid styling without flashing content. Prefer CSS classes in production, and never rely on <blink>.

🚀 Common Use Cases

  • Reading legacy tutorials — recognize HTML wrapper methods in old samples.
  • Migrating old scripts — remove blink() and use non-flashing emphasis.
  • Teaching string immutability — show that methods return new strings.
  • Not for new apps — do not use blink() to flash UI text.
  • Accessibility-first UI — use calm visual hierarchy instead of flashing attention.
  • Safer markup — prefer textContent + CSS over innerHTML strings.

🧠 How blink() Builds Markup

1

Start with text

You call str.blink() on a string receiver.

Input
2

Wrap with tags

Concatenate <blink> + text + </blink>.

Wrap
3

Return an HTML string

No DOM node is created — only text markup.

Result
4

Prefer no blink

Use static CSS styles on a real element — never rely on blinking.

📝 Notes

  • blink() is deprecated — standardized only for compatibility.
  • The <blink> element was removed from modern browsers.
  • Blinking content fails accessibility guidelines (distraction / seizure risk).
  • It returns a string, not a DOM node.
  • It takes no parameters.
  • Other HTML wrappers (big(), bold(), fontcolor(), …) share the same fate.
  • Avoid assigning untrusted strings to innerHTML.

Browser & Runtime Support

String.prototype.blink() is still widely implemented for compatibility, but it is deprecated. Do not use it in new projects.

Deprecated · Legacy

String.blink()

Available in modern browsers for old code, but MDN advises avoiding blinking elements altogether.

Legacy Compatibility only
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
blink() Avoid in new code

Bottom line: Recognize blink() in legacy samples. For new UI, emphasize text without blinking — never rely on the obsoleteelement from HTML wrapper methods.

Conclusion

String.prototype.blink() builds an obsolete <blink>...</blink> HTML string. It is useful for understanding history and migrating old code — not for writing new features.

Continue with bold(), at(), or the String methods hub.

💡 Best Practices

✅ Do

  • Use static CSS emphasis (weight, color, size) when you need attention
  • Prefer calm visual hierarchy over flashing text
  • Prefer textContent over string-built HTML
  • Replace blink() when you touch legacy files
  • Honor prefers-reduced-motion if you ever animate

❌ Don’t

  • Use blink() in new production code
  • Assume <blink> still blinks in modern browsers
  • Inject untrusted blink() output via innerHTML
  • Expect blink() to return a live element
  • Mix HTML wrappers with modern component frameworks

Key Takeaways

Knowledge Unlocked

Five things to remember about String.blink()

Deprecated HTML wrapper — do not blink text.

5
Core concepts
⚠️ 02

Status

deprecated

Legacy
03

Markup

invalid

HTML
04

Replace

no blink

Modern
05

Mutates

no

Immutable

❓ Frequently Asked Questions

String.prototype.blink() returns an HTML string that wraps the text in a <blink> element — for example "Hello".blink() returns '<blink>Hello</blink>'. It takes no parameters.
Yes. MDN marks all HTML wrapper methods as deprecated. The <blink> element was removed from modern browsers. Avoid blinking text for accessibility reasons.
The <blink> element is obsolete and no longer rendered by modern browsers. Accessibility standards also discourage blinking content because it can distract users and trigger seizures in sensitive people.
No. Strings are immutable. blink() returns a new string containing HTML markup. The original text stays the same.
Do not blink text. Prefer static emphasis with color, weight, or size. If motion is essential, use a careful CSS animation and respect prefers-reduced-motion.
The method may still return a string for compatibility, but the <blink> element itself does not blink in modern browsers. Do not use it in new code.
Did you know?

Browsers dropped <blink> because flashing text harmed usability and accessibility — emphasis belongs in careful design, not compulsory blinking. WCAG also advises against content that flashes more than a few times per second.

More String Methods

Return to the hub for slice, trim, replace, and more.

String methods hub →

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.

8 people found this page helpful