document.createElement()
The DOM method that creates a new, detached element with a given tag name, ready to be filled in and inserted into the page.
In more detail
The new element exists only in memory until you insert it with appendChild or a similar method. The course examples build a throwaway document with document.implementation.createHTMLDocument() and create elements inside it.
Related terms
- appendChild() — The DOM method that inserts a node as the last child of an element, moving it if it was already somewhere else.
- setAttribute() — The DOM method that sets an attribute on an element, with getAttribute() as its partner for reading one.
- DOM — The tree of objects a browser builds from a web page, which scripts read and change to update what is on screen.
Taught in
- HTML Parsing, Tokenization And The Document Object Model (DOM) — Frontend Architecture & Web Platform
- CSS Parsing, The CSSOM And The Render Tree — Frontend Architecture & Web Platform
- Accessibility Tree, ARIA Roles, States And Live Regions — Frontend Architecture & Web Platform