Course contentsShow
← Web Development
Lesson 2178 of 2,98240. Browser DevTools Deep DiveFree lesson

Adding and Removing Elements

Creating new elements, duplicating nodes, and deleting elements to experiment with DOM structure changes.

Adding and Removing Elements

You'll learn how to create, duplicate, and delete DOM elements in DevTools to experiment with page structure without touching source code.

The Concept

The Elements panel isn't just for viewing—it's a live playground for your page's DOM. You can create entirely new elements, clone existing ones, and delete parts of the structure to test ideas instantly. This is invaluable for prototyping layouts, debugging positioning issues, or understanding how elements interact before writing actual code.

Think of it like working with LEGO bricks: you can snap new pieces into your structure, duplicate interesting sections, or remove parts to see what happens—all without affecting your original blueprint (source files).

How It Works in DevTools

Creating new elements: Right-click any element in the Elements panel and choose "Edit as HTML." You can type new HTML directly into the existing structure. Alternatively, right-click and select "Duplicate element" to clone an element with all its attributes and children.

Adding elements: After editing HTML or duplicating, new elements appear immediately in the rendered page. You can then drag them to different positions in the DOM tree to test placement.

Removing elements: Right-click any element and select "Delete element" (or press Delete/Backspace after selecting). The element vanishes from both the DOM tree and the rendered page instantly, letting you see how the layout reflows without it.

Use cases: Test how a page looks without a navigation bar, duplicate a card component to see grid behavior with more items, or add temporary wrapper divs to diagnose CSS issues.

Remember: all changes exist only in your browser session. Refresh the page and everything reverts to the original source code.

Key Takeaway: DevTools lets you create, duplicate, and delete DOM elements in real-time to safely experiment with page structure before modifying actual code.