innerHTML
innerHTML is a DOM element property that gets or sets the serialized HTML markup representing an 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 →
Also covered in
- Vanilla WebIn early access (MEAP)
What to know first
- HTMLHTML is the standard markup language for structuring content and elements in documents on the web.
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.
- textContentcontrasts with · The textContent property gets or sets the plain text content of a DOM node and its descendants without parsing markup.
- 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.
Questions about innerHTML
What is innerHTML?
innerHTML is a DOM element property that gets or sets the serialized HTML markup representing an element’s child content.
Which Manning books explain innerHTML?
Web Components in Action and Secrets of the JavaScript Ninja, Second Edition.
What should I know before learning innerHTML?
Manning books that teach innerHTML usually introduce HTML first.
What is the difference between innerHTML and textContent?
innerHTML is a DOM element property that gets or sets the serialized HTML markup representing an element’s child content. The textContent property gets or sets the plain text content of a DOM node and its descendants without parsing markup.
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.

