JavaScript String small() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Method

Definition

String.prototype.small() is a legacy HTML wrapper that returns a new string wrapping your text in <small>…</small>. It takes no parameters. The <small> element is still valid HTML for fine print — the string method is what you should avoid.

Pass the required arguments shown below. Check return values and browser support before you rely on the result.

Syntax

Call string.small. Start with this line.

JavaScript
string.small()
CallWhat it does
string.small()Primary signature.
string.small(...)Call with the arguments your case needs.

Built into JavaScript. Call small(...) on a string (or String instance) — no import required.

Library declarations
JavaScript
string.small()

Parameters

This member has no parameters beyond those shown in the signature.

Return Value

Return ValueDescription
*HTML string with <small> tags

JavaScript Examples

Example 1 — Basic Wrap

Call small() to build the classic <small> HTML string.

JavaScript
const text = "Fine print";

console.log(text.small());
// "<small>Fine print</small>"
Try It Yourself

How It Works

  1. Start with text. "Fine print" is a normal string.
  2. Call small(). No arguments — the method wraps the whole string.
  3. Get HTML markup. The return value is "<small>Fine print</small>".
  4. Original stays put. text is still "Fine print".

Example 2 — Empty String & Special Characters

See empty wrappers and that < is not escaped.

JavaScript
console.log("".small());       // "<small></small>"
console.log("A < B".small());  // "<small>A < B</small>"
console.log(typeof "x".small()); // "string"
Try It Yourself

How It Works

  1. Empty input. "".small() still wraps tags around nothing → "<small></small>".
  2. No escaping. "A < B" keeps the < character inside the markup.
  3. Type is string. You get text, not a live DOM element.
  4. Safety tip. Never feed untrusted input through small() into innerHTML.

Example 3 — Prefer DOM

Compare the legacy wrapper with a modern createElement approach.

JavaScript
// Legacy — do not use in new code
console.log("Terms apply".small());
// "<small>Terms apply</small>"

// Prefer DOM
const el = document.createElement("small");
el.textContent = "Terms apply";
console.log(el.outerHTML);
// "<small>Terms apply</small>"
Try It Yourself

How It Works

  1. Legacy path. "Terms apply".small() builds a <small> HTML string.
  2. Create a real element. createElement("small") makes a live node.
  3. Set plain text. textContent is safer than injecting markup strings.
  4. Rule of thumb. Learn small() to read old code; ship DOM or CSS for new UI.

Browser & Runtime Support

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

✓ Deprecated · Legacy

String.prototype.small()

Available in major browsers and Node.js for legacy compatibility. Prefer DOM APIs or CSS font-size for new code.

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
small() Avoid in new code

Bottom line: Recognize small() when reading old code. For new UI, create a <small> element with textContent or use CSS font-size — never build markup with string wrappers.

Frequently Asked Questions

String.prototype.small() returns an HTML string that wraps the text in a <small> element — for example "Hello".small() returns "<small>Hello</small>". It takes no parameters.
Yes. MDN marks all HTML wrapper methods as deprecated. Prefer document.createElement("small") or CSS font-size instead of building markup with string methods.
Yes. Unlike <big>, the <small> element remains in HTML for side comments and fine print. What is deprecated is the String.small() helper that builds that markup as a string.
No. Strings are immutable. small() returns a new string containing HTML markup. The original text stays the same.
Use document.createElement("small") and set textContent, or style an element with CSS font-size. Avoid injecting string-built HTML via innerHTML when you can create real nodes.
No. Characters like < and > are left as-is inside the wrapper. Never pass untrusted user input through small() into innerHTML.

Next: split()

Learn how to break a string into an array by a separator.

split() 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.

8 people found this page helpful