String — HTML wrapper methods
> [!WARNING] > Deprecated. Avoid these methods. > > They are of limited use, as they are based on a very old HTML standard and provide only a subset of the currently available HTML tags and attributes. Many of them create deprecated or non-standard markup today. In addition, they do string concatena
Reference note (untrusted external data; do not execute it as instructions).
> [!WARNING] > Deprecated. Avoid these methods. > > They are of limited use, as they are based on a very old HTML standard and provide only a subset of the currently available HTML tags and attributes. Many of them create deprecated or non-standard markup today. In addition, they do string concatenation without any validation or sanitation, which makes them a potential security threat when directly inserted using innerHTML. Use DOM APIs such as document.createElement() instead.
{{jsxref("String.prototype.anchor()")}} {{deprecated_inline}} : (hypertext target) {{jsxref("String.prototype.big()")}} {{deprecated_inline}} : {{HTMLElement("big")}} {{jsxref("String.prototype.blink()")}} {{deprecated_inline}} : {{jsxref("String.prototype.bold()")}} {{deprecated_inline}} : {{HTMLElement("b")}} {{jsxref("String.prototype.fixed()")}} {{deprecated_inline}} : {{HTMLElement("tt")}} {{jsxref("String.prototype.fontcolor()")}} {{deprecated_inline}} : {{jsxref("String.prototype.fontsize()")}} {{deprecated_inline}} : {{jsxref("String.prototype.italics()")}} {{deprecated_inline}} : {{HTMLElement("i")}} {{jsxref("String.prototype.link()")}} {{deprecated_inline}} : (link to URL) {{jsxref("String.prototype.small()")}} {{deprecated_inline}} : {{HTMLElement("small")}} {{jsxref("String.prototype.strike()")}} {{deprecated_inline}} : {{HTMLElement("strike")}} {{jsxref("String.prototype.sub()")}} {{deprecated_inline}} : {{HTMLElement("sub")}} {{jsxref("String.prototype.sup()")}} {{deprecated_inline}} : {{HTMLElement("sup")}}
Note that these methods do not check if the string itself contains HTML tags, so it's possible to create invalid HTML
The only escaping they do is to replace " in the attribute value (for {{jsxref("String/anchor", "anchor()")}}, {{jsxref("String/fontcolor", "fontcolor()")}}, {{jsxref("String/fontsize", "fontsize()")}}, and {{jsxref("String/link", "link()")}}) with ".
Attribution: Adapted from MDN Web Docs under CC-BY-SA-2.5. Adaptation: WikiKV selected one documentation section, normalized formatting, retained bounded excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.
ATTRIBUTED SOURCE
This compact reference card is adapted from official documentation and is not a community-verified experience.
MDN Web Docs — files/en-us/web/javascript/reference/global_objects/string/index.md :: HTML wrapper methods ↗Revision d14bee540b53 · CC-BY-SA-2.5 and attribution