set:html

The set:html directive injects a raw HTML string as an element's inner content without escaping.

Since Astro 1.0 Spec ↗

Syntax

<article set:html={htmlString} />

Examples

---
const rendered = '<p>Trusted <strong>markup</strong></p>';
---
<div set:html={rendered} />
Output
Renders the HTML string as live markup, showing a paragraph with bold text.

Notes

Bypasses Astro's automatic escaping, so only use it with trusted or sanitized content to avoid XSS. Use it on the <Fragment> element when you do not want a wrapper. Prefer set:text for plain text.

See also