Raw HTML
Raw HTML is markup held as a string. The v-html marker tells Vue to show that string as markup.
Show markup as markup
This line shows the bold markup as bold text.
<p v-html="markup"></p>Show markup as text
This line shows the same string as plain text.
<p>{{ markup }}</p>Example
<script setup>
const markup = '<strong>Bold text</strong>'
</script>
<template>
<div>
<p v-html="markup"></p>
<p>{{ markup }}</p>
</div>
</template>Key points
- Raw HTML is markup held as a string.
- A string is text inside quotes.
- The v-html marker tells Vue to show the string as markup.
- Plain interpolation shows the same string as text instead.
In this example, the script block holds a plain const. The const is named markup. Its value holds bold markup as a string. The first line uses v-html. It shows Bold text in bold. The second line uses interpolation. It shows the string as plain text.
Note
Use v-html only with markup the app itself holds.
Try it Yourself
Edit the code, then press Run.
Running is simulated
Exercise
Which marker shows a string as markup?