HTML: Glossary
Tags
In HTML, the <div>
, <p>
, etc are called tags.
The <p>
is “opening tag”, and </p>
is “closing tag”.
Note, some element do not have a closing tag. 〔see List of HTML Self-Closing Tags〕
Elements
The complete <div>…</div>
, <p>…<p>
, etc are called elements. We say, “div element”, “paragraph element”, etc.
Attributes
Each HTML element has attributes, such as id=val
, class=val
, href=val
etc. The “id”
in
id=val
is the attribute name, and
val
is its value.
Node
- “Node” is a node of tree of Document Object Model (aka DOM).
- A HTML element is a node.
- A XML element is a node.
- The xyz in
<p>xyz</p>
is a node, a text node. - Whitespace between elements is also a node.
JS and DOM, Objects and Properties
When HTML is parsed by browser into DOM (Document Object Model), the HTML “element” is called object or node, and HTML attributes become properties of the object.
DOM object can have any properties, not one-to-one map with HTML attribute. Because DOM is like a language runtime. The properties are like instance variables. JavaScript can add arbitrary properties (which is key/value pair) to any DOM object, in general.