Web site traffic - 41Chapter 4Browser and Document ObjectsNode TerminologyW3C DOM terminology
41Chapter 4Browser and Document ObjectsNode TerminologyW3C DOM terminology uses metaphors to assist programmers in visualizing the containmenthierarchy of a document and its content. One concept you should grasp early in your learningis that of a node; the other concept is the family relationship among objects in a document. About nodesWhile the English dictionary contains numerous definitions of node, the one that comesclosest to its application in the W3C DOM is the one that implies a knob or bump on a treebranch. Such nodules on a branch usually lead to one of two things: a leaf or another branch. A leaf is a dead end in that no further branches emanate from the leaf; but the branch kind ofnode leads to a new branch that can, itself, have further nodes, whether they be leaves ormore branches. When you define the structure of an HTML document, you also define a nodestructure (also called a node tree) whose placement of branches and leaves depends entirelyon your HTML elements and text content. In the W3C DOM, the fundamental building block is a simple, generic node. But inside anHTML document, we work with special kinds of nodes that are tailored to HTML documents. The two types of nodes that scripts touch most often are element nodes and text nodes. These node types correspond exactly to HTML elements and the text that goes between anelement s start and end tags. You ve been working with element and text nodes in your HTMLauthoring, and you didn t even know it. Look again at the simple document assembled earlier, along with its containment hierarchydiagram in Figure 4-12. All of the boxes representing HTML elements (html, head, body, p, and em) are element nodes; the three boxes containing actual text that appears in the ren- dered document are text nodes. You saw in the transition from one long text node (Figure 4-10) to the insertion of the emelement (Figure 4-11) that the long text node divided into threepieces. Two text node pieces stayed in the same position in the hierarchy relative to the con- taining pelement. The new emelement bullied its way into the tree between the two textnodes, and shifted the third text node one level away from the pelement. Figure 4-12:A simple HTML document node tree. documenthtmlheadbodyp one and only
This is the one and only paragraph.
em paragraph. This is the