DEV Community

Cover image for Nodes vs Elements
GiandoDev
GiandoDev

Posted on

2

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.

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay