JavaScript Element append() Method

Beginner
⏱️ 11 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Baseline
Instance method

What You’ll Learn

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

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!

This page is part of JavaScript Element. Related topics include after() and appendChild().

Understanding the append() Method

Calling el.append(...nodes) inserts each argument at the end of el’s child list, in the order you pass them.

  • It is an instance method on Element (ParentNode mixin).
  • Arguments can be Node objects or strings (as Text).
  • Multiple arguments append in the order given.
  • Existing nodes in the document are moved, not cloned.
  • Return value is undefined (unlike appendChild).
  • MDN: append is unscopable—unavailable inside a with statement.

📝 Syntax

General forms of Element.append (MDN):

JavaScript
append(param1)
append(param1, param2)
append(param1, param2, /* …, */ paramN)

Parameters

  • param1, …, paramN — a set of Node objects or strings to insert. Strings are inserted as equivalent Text nodes.

Return value

None (undefined).

Exceptions

  • HierarchyRequestError DOMException — 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

⚡ Quick Reference

GoalCode
Append one elementel.append(child)
Append textel.append("Hello")
Append several itemsel.append(a, " ", b)
Classic single-node APIel.appendChild(child)
Return valueundefined
MDN statusBaseline Widely available (since April 2018)

🔍 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

📋 append() vs appendChild()

el.append(...)parent.appendChild(node)
Accepts strings?Yes (as Text)No — Node only
Multiple args?YesOne node per call
Return valueundefinedAppended node
Works onElement (ParentNode)Any Node parent
Existing nodeMovesMoves
Best forModern multi + text insertsClassic single-node / chaining patterns

MDN also notes three differences: strings allowed, no return value, and several nodes/strings in one call.

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> ]
Try It Yourself

How It Works

p becomes the last (and only) child of div. childNodes.length is 1.

Example 2 — Appending Text (MDN)

Pass a string; the browser creates a Text node.

JavaScript
let div = document.createElement("div");
div.append("Some text");

console.log(div.textContent); // "Some text"
Try It Yourself

How It Works

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> ]
Try It Yourself

How It Works

First the Text node “Some text”, then the empty <p>—both as children of div.

Example 4 — Several Children in One Call

Build a small list item content trail with mixed nodes.

JavaScript
const item = document.getElementById("item");
const badge = document.createElement("strong");
badge.textContent = "NEW";
const note = document.createElement("em");
note.textContent = "sale";

item.append("Shoes ", badge, " — ", note);

console.log(item.innerHTML);
// Shoes <strong>NEW</strong> — <em>sale</em>
Try It Yourself

How It Works

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)
Try It Yourself

How It Works

a leaves its old position and becomes the last child. Use cloneNode(true) if you need a duplicate instead.

🚀 Common Use Cases

  • Building list items or cards with mixed text and elements in one call.
  • Appending labels without creating Text nodes by hand.
  • Replacing several appendChild calls with a single append.
  • Moving an existing child to the end of a container.
  • Teaching ParentNode helpers vs classic Node methods.
  • Pairing with after() / prepend for clear DOM placement.

🧠 How append() Adds Children

1

Call on the parent element

You invoke el.append(...) on the container that should gain children.

Parent
2

Normalize arguments

Strings become Text nodes; existing nodes may detach from their old place.

Prepare
3

Insert at the end

New nodes become the last children, in argument order.

Append
4

DOM updated; return undefined

Check childNodes or innerHTML—there is no return payload.

📝 Notes

  • Not Deprecated, Experimental, or Non-standard on MDN (Baseline Widely available since April 2018).
  • append() inserts children of the element—not siblings.
  • Return value is always undefined.
  • Invalid hierarchy can raise HierarchyRequestError.
  • MDN: append is unscopable (not available inside with).
  • Related: appendChild(), after(), children, JavaScript hub.

Browser Support

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.

Baseline Widely available
Google Chrome Supported · Desktop & Mobile
Yes
Microsoft Edge Supported · Chromium
Yes
Mozilla Firefox Supported · Desktop & Mobile
Yes
Apple Safari Supported · macOS & iOS
Yes
Opera Supported · Modern versions
Yes
Internet Explorer Not 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.

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.

Continue with appendChild(), after(), children, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Use append() for multiple nodes + strings
  • Pass strings when you need Text nodes quickly
  • Expect moves when reusing an existing node
  • 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

Key Takeaways

Knowledge Unlocked

Five things to remember about Element.append()

Add last children—nodes or text, one call.

5
Core concepts
📄 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.

More Element Topics

Browse Element methods and properties to keep building DOM skills.

after() →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful