String.prototype.strike() is a deprecated HTML wrapper method (same API as MDN String.prototype.strike()). It returns a string that wraps your text in a <strike> tag. Learn what it builds, why that element is obsolete, and how to replace it with <s> / <del> — 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
<s> or <del>
Fundamentals
Introduction
Early JavaScript included helpers that wrapped text in HTML presentation tags — strike(), big(), bold(), italics(), and others. They made it easy to inject markup with innerHTML.
Today those wrappers are deprecated. strike() still works in browsers for compatibility, but the <strike> element itself was removed from HTML. Use semantic strikethrough with <s> or <del> instead.
💡
Learn it, don’t ship it
Study strike() so you can recognize legacy code. For new pages, create a real <s> or <del> node — or use CSS text-decoration: line-through when the look is only visual.
Unlike some attribute wrappers, strike() does not escape < inside the text. That is another reason to avoid injecting untrusted strings via innerHTML.
📈 Practical Patterns
Legacy injection patterns and the modern DOM 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.strike();
// document.body.innerHTML = html; // legacy pattern — avoid in new apps
console.log(html);
// Warning: is not a valid element in modern HTML
You get a live element and valid markup. Use <del> when the text was removed as an edit; use CSS line-through when the look is only decorative.
Applications
🚀 Common Use Cases
Reading legacy tutorials — recognize HTML wrapper methods in old samples.
Migrating old scripts — replace strike() with createElement("s") or "del".
Price / outdated labels — use a real <s> for “no longer accurate” text.
Document edits — use <del> (often with <ins>) for tracked changes.
Not for new apps — do not use strike() to draw strikethrough.
Safer markup — prefer textContent + DOM over innerHTML strings.
🧠 How strike() Builds Markup
1
Start with text
You call str.strike() on a string receiver.
Input
2
Wrap with tags
Concatenate <strike> + text + </strike>.
Wrap
3
Return an HTML string
No DOM node is created — only text markup.
Result
4
⚠️
Prefer <s> / <del> instead
Create a semantic element with createElement.
Important
📝 Notes
strike() is deprecated — standardized only for compatibility.
The <strike> element was removed from the HTML specification.
Prefer <s> (inaccurate / irrelevant) or <del> (deleted content).
It returns a string, not a DOM node.
It takes no parameters.
Avoid assigning untrusted strings to innerHTML.
Compatibility
Browser & Runtime Support
String.prototype.strike() is still widely implemented for compatibility, but it is deprecated. Do not use it in new projects.
✓ Deprecated · Legacy
String.strike()
Available in modern browsers for old code, but MDN recommends createElement("s") or createElement("del") instead.
LegacyCompatibility only
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
strike()Avoid in new code
Bottom line: Recognize strike() in legacy samples. For new UI, create a real or element — never rely on the obsolete tag from HTML wrapper methods.
Wrap Up
Conclusion
String.prototype.strike() builds an obsolete <strike>...</strike> HTML string. It is useful for understanding history and migrating old code — not for writing new features.
Mix HTML wrappers with modern component frameworks
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about String.strike()
Deprecated HTML wrapper — prefer <s> or <del>.
5
Core concepts
📝01
Returns
HTML string
API
⚠️02
Status
deprecated
Legacy
❌03
Markup
invalid
HTML
✓04
Replace
<s> / <del>
Modern
⚡05
Mutates
no
Immutable
❓ Frequently Asked Questions
String.prototype.strike() returns an HTML string that wraps the text in a <strike> element — for example "Hello".strike() returns '<strike>Hello</strike>'. It takes no parameters.
Yes. MDN marks all HTML wrapper methods as deprecated. The <strike> element itself was removed from the HTML specification. Prefer <s> or <del> created with document.createElement().
The <strike> element is obsolete. Modern HTML uses <s> for content that is no longer accurate or relevant, and <del> for deleted content (often with an edit history).
No. Strings are immutable. strike() returns a new string containing HTML markup. The original text stays the same.
Use document.createElement("s") or document.createElement("del"), and set textContent. You can also style text with CSS text-decoration: line-through when the meaning is purely visual.
It remains widely available for compatibility, but you should not use it in new code.
Did you know?
<strike> and <s> both drew a line through text historically, but modern HTML dropped <strike> and kept <s> with a clearer meaning (content that is no longer accurate or relevant). <del> is for deletions — often paired with <ins>.