loading...
Cover image for Nodes vs Elements

Nodes vs Elements

giandodev profile image GiandoDev ・1 min read

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.

Posted on May 23 by:

giandodev profile

GiandoDev

@giandodev

Hi, I am Giandomenico. I love to learn new stuff and solve problems.

Discussion

markdown guide