HTML wrapper methods
The anchor() method of String values creates a string that embeds this string in an <a> element with a name (<a name="...">str</a>).
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
String.anchor Deprecated | 1 | 12 | 1 | 1 | 18 | 1 |
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.
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.