beforebegin. Text node sits just before the target.
afterend. Text node sits just after the target.
Parent required. MDN: these positions need an element parent in the tree.
Inside vs outside. Use afterbegin/beforeend to stay inside the element.
Compatibility
Browser Support
Element.insertAdjacentText() is Baseline Widely available (MDN: across browsers since April 2018). Safe for modern teaching and production code.
✓ Baseline · Widely available
insertAdjacentText()
Insert a plain text node at a position relative to an element.
WideBaseline
Google ChromeFull support
Supported
Mozilla FirefoxFull support
Supported
Apple SafariFull support
Supported
Microsoft EdgeFull support
Supported
OperaFull support
Supported
Internet ExplorerLimited / prefer modern
Partial
insertAdjacentText()Widely available
Bottom line: Use insertAdjacentText whenever the content must remain plain text — especially user-provided strings.
Frequently Asked Questions
It inserts a new text node at a position relative to the element (MDN). You pass a position string and plain text — the string is not parsed as HTML.
No. MDN marks Element.insertAdjacentText() as Baseline Widely available (across browsers since April 2018). It is not Deprecated, Experimental, or Non-standard.
Nothing useful — the return value is undefined (MDN).
insertAdjacentText() creates a Text node from a plain string. insertAdjacentHTML() parses HTML markup, which can be unsafe with user input (MDN).
beforebegin, afterbegin, beforeend, and afterend — the same four slots as insertAdjacentHTML() and insertAdjacentElement() (MDN).
When content should stay plain text — for example user comments, labels, or chat messages. Tags like <b> are shown as characters, not markup.