v-html

Sets an element's innerHTML from a string expression.

Since Vue 3.0 Spec ↗

Syntax

v-html="htmlString"

Parameters

NameTypeRequiredDescription
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.