innerHTML
Edit this pageinnerHTML sets an element's innerHTML property.
Syntax
<div innerHTML={html} />Value
- Type:
string
HTML string inserted as raw markup into the element.
Behavior
- Setting
innerHTMLreplaces the element's existing children with nodes parsed from the string. - The value is written through the DOM
innerHTMLproperty. - In SSR output, the HTML string is emitted as child content without escaping.
- Unlike
textContent,innerHTMLparses markup instead of inserting plain text.
caution
Using innerHTML with unsanitized user-supplied data can introduce security vulnerabilities.
Examples
Basic usage
<div innerHTML={"<strong>Hello</strong>"} />