innerHTML
innerHTML is a DOM element property that gets or sets the serialized HTML markup representing the element’s child content.
Web Components in Action
innerHTML is a DOM property that gets or sets the serialized HTML markup contained within an element.
- How it is used
- Populates custom elements with markup and clears their contents when replacing a template-driven layout.
- How deep it goes
- Works through assignments, lifecycle timing, clearing, and exposed DOM; does not examine markup serialization internals.
- Examples
- Uses a slider, photo carousel, constructor failure, template-switched business card, and externally modified component.
- What you can do after
- Build it from scratch: populate a custom element in connectedCallback, then select its children for styling or interaction.
Secrets of the JavaScript Ninja, Second Edition
A DOM element property that gets or sets HTML markup as the serialized contents of an element.
- How it is used
- Converts an HTML string into DOM nodes by parsing it inside a temporary element.
- How deep it goes
- Details markup preprocessing, required wrappers, insertion, and node extraction without developing getter behavior.
- Examples
- Uses option elements and table markup, including a self-closing table tag, to illustrate parsing constraints.
- What you can do after
- Build a DOM-node list from an HTML string by preparing markup, wrapping it, and extracting parsed children.
Read how Secrets of the JavaScript Ninja, Second Edition explains innerHTML →
Related concepts
- HTML stringuses · An HTML string is a character sequence containing markup in HTML syntax that can be parsed into document or fragment nodes.
- queryselectorused by · querySelector is a DOM method that returns the first element matching a specified CSS selector within a document or element subtree.
- cross-site scripting attackcontrasts with · Cross-site scripting is a web security vulnerability in which attacker-controlled content causes executable script to run in another user’s browser within a trusted application context.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

