v-html
Sets an element's innerHTML from a string expression.
Syntax
v-html="htmlString" Parameters
| Name | Type | Required | Description |
|---|---|---|---|
htmlString | string | No | Raw HTML to inject as the element's content. |
Returns
directive — Replaces inner content with parsed HTML.
Examples
<script setup lang="ts">
import { ref } from 'vue';
const markup = ref('<strong>Bold</strong> text');
</script>
<template>
<div v-html="markup"></div>
</template>
Notes
v-html renders raw HTML and bypasses Vue's escaping, so only use it with
trusted or sanitized content to avoid XSS. It overrides any element children
and does not compile Vue template syntax inside the string. Prefer text
interpolation or components when possible.