Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Interactive Web Pages with JavaScript Traversing and Manipulating the DOM with JavaScript Perform: Appending and Removing Elements

Kartik Kapoor
Kartik Kapoor
3,016 Points

What is the difference between a node and an element?

8

2 Answers

Saichand Pullepu
Saichand Pullepu
11,905 Points

Node can have multiple elements like parent, child, Sibling. But Elements refer to single element.

Kartik Kapoor
Kartik Kapoor
3,016 Points

Thanks for the clarification :).

Anestis Aou
Anestis Aou
6,742 Points

I had the same question earlier in the course. What is a node?

From what I read, any part of HTML document is a node.

There are ELEMENT_NODES. ATTRIBUTE_NODES, TEXT_NODES, COMMENT_NODES and others that we don't have to worry yet.
The DOM consists of a hierarchy of nodes where each node can have a parent, a list of child nodes and a nextSibling and previousSibling.

check console:

document instanceof Node ->true

document instanceof Element -> false

document.firstChild -> <html >HTML TAGS</html>

document.firstChild instanceof Node -> true

document.firstChild instanceof Element -> true