Element.append() is an instance method from the ParentNode API. It inserts nodes or strings after the last child of the element. Learn multi-argument appends, text coercion, how it compares to appendChild(), and five try-it labs.
01
Kind
Instance method
02
Inserts
After last child
03
Args
Nodes or strings
04
Returns
undefined
05
vs appendChild
Multi + strings
06
Status
Baseline widely
Fundamentals
Introduction
appendChild() adds one node at a time. append() is the modern ParentNode helper: add several nodes and plain strings in a single call, all as the new last children of the element.
Strings become Text nodes automatically—no createTextNode required for simple labels.
💡
Beginner tip
append() adds children inside the element. after() adds siblings after the element. Different place in the tree!
param1, …, paramN — a set of Node objects or strings to insert. Strings are inserted as equivalent Text nodes.
Return value
None (undefined).
Exceptions
HierarchyRequestErrorDOMException — thrown when the node cannot be inserted at the specified point in the hierarchy (MDN).
Common patterns
JavaScript
const div = document.createElement("div");
const p = document.createElement("p");
div.append(p); // one element
div.append("Some text"); // one Text node
div.append("Hi ", p, "!"); // text + element + text
div.append(span1, span2); // several elements
Cheat Sheet
⚡ Quick Reference
Goal
Code
Append one element
el.append(child)
Append text
el.append("Hello")
Append several items
el.append(a, " ", b)
Classic single-node API
el.appendChild(child)
Return value
undefined
MDN status
Baseline Widely available (since April 2018)
Snapshot
🔍 At a Glance
Four facts to remember about Element.append().
Returns
undefined
Updates the DOM in place
Baseline
widely
Since April 2018
Where
last children
End of el’s child list
Strings
→ Text
Auto Text nodes
Compare
📋 append() vs appendChild()
el.append(...)
parent.appendChild(node)
Accepts strings?
Yes (as Text)
No — Node only
Multiple args?
Yes
One node per call
Return value
undefined
Appended node
Works on
Element (ParentNode)
Any Node parent
Existing node
Moves
Moves
Best for
Modern multi + text inserts
Classic single-node / chaining patterns
MDN also notes three differences: strings allowed, no return value, and several nodes/strings in one call.
Hands-On
Examples Gallery
Examples follow MDN Element.append() patterns. Use View Output or Try It Yourself for each case.
📚 Getting Started
Append an element, text, or both—matching MDN’s core demos.
Example 1 — Appending an Element (MDN)
Create a <p> and append it into a <div>.
JavaScript
let div = document.createElement("div");
let p = document.createElement("p");
div.append(p);
console.log(div.childNodes); // NodeList [ <p> ]
No createTextNode needed. appendChild cannot do this with a raw string.
📈 Practical Patterns
Mix text and elements, append several children, and move existing nodes.
Example 3 — Element and Text Together (MDN)
Pass a string and an element in one call—order is preserved.
JavaScript
let div = document.createElement("div");
let p = document.createElement("p");
div.append("Some text", p);
console.log(div.childNodes);
// NodeList [ #text "Some text", <p> ]
One call appends four nodes: text, strong, text, em—in that order at the end of item.
Example 5 — Moving an Existing Node
If the node is already in the document, append() relocates it.
JavaScript
const list = document.getElementById("list");
const a = document.getElementById("a");
const b = document.getElementById("b");
list.append(a);
console.log([...list.children].map((el) => el.id).join(", "));
// "b, a" (a moved to the end)
Element.append() is Baseline Widely available (MDN: across browsers since April 2018). Logos use the shared browser-image-sprite.png sprite from this project.
✓ Baseline Widely available
Element.append()
Safe for production. Prefer append() when you need strings or multiple children in one call.
BaselineWidely available
Google ChromeSupported · Desktop & Mobile
Yes
Microsoft EdgeSupported · Chromium
Yes
Mozilla FirefoxSupported · Desktop & Mobile
Yes
Apple SafariSupported · macOS & iOS
Yes
OperaSupported · Modern versions
Yes
Internet ExplorerNot supported · Use appendChild
No
append()Excellent
Bottom line: Use append() for modern multi-node and text inserts. Use appendChild() when you need the returned child or work with non-Element Node parents.
Wrap Up
Conclusion
Element.append() is the modern way to add last children—nodes, text, or several at once. It returns undefined and updates the element’s child list in place.
Prefer append over repeated appendChild for Elements
Verify with childNodes or innerHTML
❌ Don’t
Expect a returned node (it is undefined)
Confuse append (children) with after (siblings)
Assume IE supports append()
Forget that invalid trees can throw HierarchyRequestError
Use with (el) { append(...) }—it is unscopable
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about Element.append()
Add last children—nodes or text, one call.
5
Core concepts
📝01
Returns
undefined
API
📄02
Where
end of children
Parent
✍️03
Strings
become Text
Coerce
✅04
Baseline
widely available
Status
⚡05
vs Child
multi + strings
Compare
❓ Frequently Asked Questions
It inserts one or more Node objects or strings after the last child of the element. Strings become Text nodes.
No. MDN marks Element.append() as Baseline Widely available (across browsers since April 2018). It is not Deprecated, Experimental, or Non-standard.
append() can take multiple nodes and strings, and returns undefined. appendChild() accepts only one Node and returns that child.
Nothing useful — the return value is undefined. Inspect childNodes or innerHTML to verify what was added.
Yes. Pass a string: el.append("Hello"). The browser creates a Text node for you.
Like appendChild, append moves it to the new parent. Use cloneNode() if you need a copy.
Did you know?
MDN marks append() as unscopable: inside a with (div) { … } block, calling append("foo") throws ReferenceError. Prefer normal method calls—div.append("foo")—and avoid with entirely in modern code.