Nodes vs Elements in the DOM

In my early JavaScript learning process, I came across two objects: ‘nodes’ and ‘elements’ which triggered some confusion in my mind. I thought both objects were the same, when in fact, it turns out they are not technically the same because there is a clear distinct difference between both. Let’s sort out that difference between nodes and elements.

What’s a node? it is the name of any type of object in the DOM tree. It could be one of the built-in DOM elements such as the document itself, document.head or document.body. A node could be an HTML tag specified in the HTML such as…