Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App

Related Articles

Vue.js | v-html directive

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The v-html directive is a Vue.js directive used to update a element’s inner HTML with our data. This is what separates it from v-text which means while v-text accepts string and treats it as a string it will accept string and render it into HTML. First, we will create a div element with id as app and let’s apply the v-html directive to this element with data as a message. Now we will create this message by initializing a Vue instance with the data attribute containing our message.

Scoped styles won’t apply to v-html, because Vue doesn’t compile that HTML. In order to apply styles to it try using global styles or some other CSS Modules.



Parameters: This directive accepts a single parameter which is the data in the form of a string. 
Example: This example uses VueJS to update the html of a element with v-html.


<!DOCTYPE html>
        VueJS | v-html directive
    <!-- Load Vuejs -->
    <script src=
    <div style="text-align: center;width: 600px;">
        <h1 style="color: green;">
            VueJS | v-html directive
    <div id="canvas" style="border:1px solid #000000;
                            width: 600px;height: 200px;">
        <div v-html="message" id="app">
        var app = new Vue({
            el: '#app',
            data: {
                message: '<h1>HELLO '+
                           '<span style="color:blue;">'+


My Personal Notes arrow_drop_up
Last Updated : 07 Jun, 2022
Like Article
Save Article
Similar Reads
Related Tutorials