February 2019
Beginner to intermediate
284 pages
6h 20m
English
The structure of an HTML document is normally described with tags, but it can also be specified using JavaScript commands with a Document Object Model (DOM): a language-neutral API that represents an HTML or XML document as a tree. Consider the following HTML document (Examples/example-1.html):
<html><body> <h1>Simple page</h1> <p>Simple paragraph</p> <div> <img src="pluto.jpg" width="100"/> <p>Click me!</p> </div> </body> </html>
This page builds a tree of interconnected nodes containing HTML elements and text. The exact same result can be obtained with the following JavaScript commands (Examples/example-2.html):
const html = document.documentElement; const body = document.createElement("body"); html.appendChild(body); ...Read now
Unlock full access