HTML wrapper methods
Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
The anchor() method of String values creates a string that embeds this string in an <a> element with a name (<a name="...">str</a>).
Note: All HTML wrapper methods are deprecated and only standardized for compatibility purposes. Use DOM APIs such as document.createElement() instead.
The HTML specification no longer allows the <a> element to have a name attribute, so this method doesn't even create valid markup.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
javascript.builtins.String.anchor Deprecated | 1 | 12 | 1 | 1 | 18 | 1 |
| Built-in object | ||||||
String.big Deprecated The big() method of String values creates a string that embeds this string in a big element (str), which causes this string to be displayed in a big font. | 1 | 12 | 1 | 1 | 18 | 1 |
String.blink Deprecated The blink() method of String values creates a string that embeds this string in a element (str), which used to cause a string to blink in old browsers. | 1 | 12 | 1 | 1 | 18 | 1 |
String.bold Deprecated The bold() method of String values creates a string that embeds this string in a b element (str), which causes this string to be displayed as bold. | 1 | 12 | 1 | 1 | 18 | 1 |
String.fixed Deprecated The fixed() method of String values creates a string that embeds this string in a tt element (str), which causes this string to be displayed in a fixed-width font. | 1 | 12 | 1 | 1 | 18 | 1 |
String.fontcolor Deprecated The fontcolor() method of String values creates a string that embeds this string in a font element (str), which causes this string to be displayed in the specified font color. | 1 | 12 | 1 | 1 | 18 | 1 |
String.fontsize Deprecated The fontsize() method of String values creates a string that embeds this string in a font element (str), which causes this string to be displayed in the specified font size. | 1 | 12 | 1 | 1 | 18 | 1 |
String.italics Deprecated The italics() method of String values creates a string that embeds this string in an i element (str), which causes this string to be displayed as italic. | 1 | 12 | 1 | 1 | 18 | 1 |
String.link Deprecated The link() method of String values creates a string that embeds this string in an a element (str), to be used as a hypertext link to another URL. | 1 | 12 | 1 | 1 | 18 | 1 |
String.small Deprecated The small() method of String values creates a string that embeds this string in a small element (str), which causes this string to be displayed in a small font. | 1 | 12 | 1 | 1 | 18 | 1 |
String.strike Deprecated The strike() method of String values creates a string that embeds this string in a strike element (str), which causes this string to be displayed as struck-out text. | 1 | 12 | 1 | 1 | 18 | 1 |
String.sub Deprecated The sub() method of String values creates a string that embeds this string in a sub element (str), which causes this string to be displayed as subscript. | 1 | 12 | 1 | 1 | 18 | 1 |
String.substr Deprecated The substr() method of String values returns a portion of this string, starting at the specified index and extending for a given number of characters afterwards. | 1 | 12 | 1 | 1 | 18 | 1 |
String.sup Deprecated The sup() method of String values creates a string that embeds this string in a sup element (str), which causes this string to be displayed as superscript. | 1 | 12 | 1 | 1 | 18 | 1 |
- Starting with version 17, the quotation mark (") is replaced by its HTML reference character (`"`) in strings supplied for the `name` parameter.
Syntax
// HTML wrapper methods example
// See MDN Web Docs for details Live demo
Wrap text with bold and italics
Use legacy string wrapper methods that return HTML strings.
Create an anchor tag string
Use String.prototype.link to produce a legacy HTML snippet.
Compare with template literals
See the same HTML built with a modern explicit template string.
Use cases
-
Legacy string cleanup
Replace wrapper-method output with explicit templates or DOM updates during modernization work.
-
Reading old examples
Understand wrapper methods when maintaining historical snippets or browser-era tutorials.
Cautions
- HTML-generating string helpers blur the boundary between text and markup and are easy to misuse.
- Prefer explicit rendering paths that are easier to sanitize, review, and localize.
Accessibility
- Generated HTML still needs semantic structure and safe rendering rules.
- String-based markup construction can hide accessibility issues until late in review.