Languages
[Edit]
EN

HTML - Element, Text, Comment, Node, etc. inheritance

7 points
Created by:
Rogan-Wilkes
727

In this article, we would like to show you HTML elements inheritance concept.

Every HTML element is a Node (it means HTMLElement extends Element that extends Node, etc.). As you can see, Text and Comment are located on different branches and they are also Nodes. Elements like: <div>, <p>, <img>, <br>, <body>, etc. are HTMLElements.

Overview:

How HTML elements extends / inherits from others (from Node).
How HTML elements extends / inherits from others (from Node).

Practical examples

Edit

In this section, we create instances of Text, Element, and Comment HTML elements and use instanceof operator to present the elements inheritance.

Text

Edit

Text is a node that presents text on a website. Text nodes are located in HTML elements.

HTMLElement

Edit

HTML elements build website layout. In the below example we used <div> as an example element.

Comment

Edit

Comments are useful to mark some important things in the source core. The user doesn't see them by default.

References

Edit
  1. instanceof - JavaScript | MDN 

Alternative titles

  1. HTML - Node types and its inheritance model
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join