String.prototype.sup() returns an HTML string that wraps your text in a <sup> tag (superscript). It is a deprecated HTML wrapper with no parameters and does not create a live DOM node.
Pass the required arguments shown below. Check return values and browser support before you rely on the result.
Syntax
Call string.sup. Start with this line.
JavaScript
str.sup()
Call
What it does
str.sup()
Primary signature.
string.sup(...)
Call with the arguments your case needs.
Built into JavaScript. Call sup(...) on a string (or String instance) — no import required.
Library declarations
JavaScript
str.sup()
Parameters
This member has no parameters beyond those shown in the signature.
Create a real node.createElement("sup") gives you a live element.
Set safe text.textContent avoids HTML injection from string-built tags.
Valid HTML. The <sup> element is still correct for superscripts.
Append when ready. Add the node to the document instead of assigning innerHTML.
Compatibility
Browser & Runtime Support
String.prototype.sup() is still widely implemented for compatibility, but it is deprecated. Do not use it in new projects.
✓ Deprecated · Legacy
String.sup()
Available in modern browsers for old code. MDN recommends createElement("sup") instead of string-built HTML wrappers.
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
sup()Avoid in new code
Bottom line: Recognize sup() in legacy samples. For new UI, create a real <sup> element with createElement — the tag is valid; the string method is not recommended.
Frequently Asked Questions
String.prototype.sup() returns an HTML string that wraps the text in a <sup> element — for example "2".sup() returns '<sup>2</sup>'. It takes no parameters.
Yes. MDN marks all HTML wrapper methods as deprecated. Prefer document.createElement("sup") instead of building markup with string methods.
Yes. The <sup> element remains in HTML for superscript text (like x², ordinals, or footnotes). What is deprecated is the String.sup() helper that builds that markup as a string.
No. Strings are immutable. sup() returns a new string containing HTML markup. The original text stays the same.
Yes as a pair — sub() builds <sub> and sup() builds <sup>. Both are deprecated HTML wrappers. Prefer createElement("sub") / createElement("sup").
Use document.createElement("sup") and set textContent. Avoid injecting string-built HTML via innerHTML when you can create real nodes.