Node (W3C DOM Core object)

Spec
Version Depr.
DOM1 No
Browser support (more…)
IE5.5+ FF1.5+ SA1.3+ OP9+
Partial Full Buggy Full

Example

<h1 id="greeting">Be excellent to each other</h1>

In the example above, h1 is an Element node, id="greeting" is an Attr node, and the text inside the heading is a Text node.

Description

The Node interface is the primary data type for the Document Object Model (DOM). It represents any single item in the tree, such as an Element, Attr, Document or Entity.

Whether a Node may have children depends on its type.

The following table is an overview of each of the core interfaces, showing how the nodeName and nodeType returns, and what kind of children the node is allowed to have.

Table 1. A summary of universal Node properties
Interface nodeName nodeType Children
Element The tag name, eg. HTML 1 Element, Text, Comment, ProcessingInstruction, CDATASection, EntityReference
Attr The attribute name, eg. id 2 Text, EntityReference 1
Text #text 3 Cannot have children
CDATASection #cdata-section 4 Cannot have children
EntityReference The name of the entity reference, eg. amp 5 Element, ProcessingInstruction, Comment, Text, CDATASection, EntityReference
Entity The entity name, eg. & 6 Element, ProcessingInstruction, Comment, Text, CDATASection, EntityReference
ProcessingInstruction The target of the processing instruction, eg. xml-stylesheet 7 Cannot have children
Comment #comment 8 Cannot have children
Document #document 9 Element (one only), ProcessingInstruction, Comment, DocumentType (one only)
DocumentType The name of the document type, eg. html 10 Cannot have children
DocumentFragment #document-fragment 11 Element, ProcessingInstruction, Comment, Text, CDATASection, EntityReference
Notation The notation name 12 Cannot have children

Compatibility

Internet Explorer Firefox Safari Opera
5.5 6.0 7.0 1.5 2.0 3.0 1.3 2.0 3.0 9.0 9.5
Partial Partial Partial Full Full Full Buggy Buggy Buggy Full Full

Internet Explorer doesn't implement the following:

Additionally, Internet Explorer 5.5 doesn't implement the following:

Internet Explorer has additional features in its implementation of childNodes and attributes.

Safari has bugs in its implementation of childNodes.

Safari 1.3 and 2 have bugs in their implementation of localName.

Opera has additional features in its implementation of childNodes.

All browsers have bugs in their implementation of attributes.

In this Section

Footnotes

1 Whether the value of an attribute can actually be processed as a child of the attribute node varies widely by implementation. For more details please see Attr

User-contributed notes

There are no comments yet.

Related Products