HTML - DOM (Tree)

> (World Wide) Web - (W3|WWW) > HyperText markup Language (HTML)

1 - About

Advertising

3 - Example of DOM Tree

example of HTML DOM tree

<!-- tells the browser what language it's reading -->
<!DOCTYPE html>
<!-- Starts the HTML document -->
<html>
 <head>
  <title>Sample page</title>
 </head>
 <body>
  <h1>Sample page</h1>
  <p>This is a <a href="demo.html">simple</a> sample.</p>
  <!-- this is a comment -->
 </body>
<!-- Ends the HTML document -->
</html>
DOCTYPE: html
html
    head
        #text: ???
        title
            #text: Sample page
        #text: ??
    #text: ??
    body
        #text: ???
        h1
            #text: Sample page
        #text: ???
        p
            #text: This is a
            a href="demo.html"
                 #text: simple
            #text: sample.
        #text: ???
        #comment: this is a comment
        #text: ???

The root element of this tree is the html element, which is the element always found at the root of HTML documents. It contains two elements, head and body, as well as a Text node between them.

The head element contains a title element, which itself contains a Text node with the text “Sample page”. Similarly, the body element contains an h1 element, a p element, and a comment.

web/html/dom.txt · Last modified: 2019/02/09 11:41 by gerardnico