DEV Community

Cover image for Nodes vs Elements
GiandoDev
GiandoDev

Posted on

Nodes vs Elements

Alt Text
image source
In this image above we see our html and the rappresentation of it in the DOM. In the image above all the html is a node and also an element. The element is a special type of node.
This is the list of all types of node not deprecated:

  • Element node
  • Text node
  • Processing instruction node
  • Comment node
  • Document node
  • Document type node
  • Document fragment node Nodes have properties and methods; the two most used are Node.parentElement that returns the parent element if it exists, if it does not exist or if it is not an element, returns null. Alt Text image source

The second is Node.textContent that sets / returns the textual content of an element and all its descendants.
Elements are also nodes but they have also another set of properties and methods that you may use with them. We will see them soon.

Top comments (0)