---
title: "Template Syntax ≒ HTML | Progressive Vue"
description: "Vue's templates are HTML itself — with just a few extensions"
last_updated: "2026-11-15"
canonical_url: "https://wtrclred.vercel.app/books/progressive-vue/03"
language: "en"
---

# Template Syntax ≒ HTML | Progressive Vue

Turn on watercolor background effects. * May affect performance, battery life, and temperature on some devices.

### Table of Contents

- [Templates Are HTML](#templates-are-html)
- [Mustache Syntax: {{ }}](#mustache-syntax)
- [v-for: Loops](#v-for-loops)
- [v-bind: Attribute Binding](#v-bind-attribute-binding)
- [v-if / v-else: Conditional Rendering](#v-if-v-else-conditional-rendering)
- [Templates Are Not "Another Language"](#templates-are-not-another-language)
- [Summary](#summary)

## Templates Are HTML

 Before learning Vue's template syntax, let me state the most important point.

 Vue templates are valid HTML.

 Unlike JSX, you don't write HTML inside JavaScript.

You write HTML, and add just a few Vue-specific attributes.

The browser's HTML parser can interpret them as legitimate HTML.

 This is at the core of Vue's design philosophy.

## Mustache Syntax: {{ }}

 To display data in the template, use `{{ }}` (Mustache syntax).

 Let's start with the simplest example.

 

```html
  <  div   id  =  "app"  > 
   <  h1  > {{ message }} <  /  h1  > 
 <  /  div  > 

 <  script   type  =  "importmap"  > 
  { "imports": { "vue": "https://unpkg.com/vue@3/dist/vue.esm-browser.js" } }
 <  /  script  > 
 <  script   type  =  "module"  > 
  import { createApp, ref } from "vue";

  createApp({
    setup() {
      const message = ref("My Bookshelf");
      return { message };
    },
  }).mount("#app");
 <  /  script  >
```

 `{{ message }}` gets replaced with the value of `message` defined in `setup()`.

The rest of the template remains just HTML .

## v-for : Loops

 Instead of copy-pasting HTML, generate a list from an array.

 

```html
  <  div   id  =  "app"  > 
   <  h1  > My Bookshelf <  /  h1  > 
   <  p  > A record of recently read books. <  /  p  > 

   <  div   class  =  "card"   v-for  =  "book in books"  > 
     <  h2  > {{ book.title }} <  /  h2  > 
     <  p  > {{ book.description }} <  /  p  > 
     <  span   class  =  "tag"   v-for  =  "tag in book.tags"  >  {{ tag }}  <  /  span  > 
   <  /  div  > 
 <  /  div  >
```

 `v-for="book in books"` — this is a Vue directive.

It's written as an HTML attribute, right where you'd write `class` or `id`.

 Notice that the template structure is nearly identical to the static HTML from the previous chapter.

 Static HTML
 Vue Template

 ` `
 ` `

 ` Readable Code `
 ` {{ book.title }} `

 ` programming `
 ` {{ tag }} `

 The HTML structure stays the same. One attribute added, text replaced with `{{ }}`.

This is the template DSL (Domain Specific Language). It extends HTML without breaking it.

## v-bind : Attribute Binding

 You can bind data to HTML attributes, not just text content.

 

```html
  <  a   v-bind:href  =  "book.url"  > {{ book.title }} <  /  a  >
```

 There's a shorthand — just `:`.

 

```html
  <  a   :href  =  "book.url"  > {{ book.title }} <  /  a  >
```

 Again, written in the HTML attribute position.

Not special syntax — just binding data to an attribute value.

## v-if / v-else : Conditional Rendering

 

```html
  <  div   class  =  "card"   v-for  =  "book in books"  > 
   <  h2  > {{ book.title }} <  /  h2  > 
   <  p  > {{ book.description }} <  /  p  > 
   <  p   v-if  =  "book.tags.length === 0"  > No tags <  /  p  > 
   <  div   v-else  > 
     <  span   class  =  "tag"   v-for  =  "tag in book.tags"  >  {{ tag }}  <  /  span  > 
   <  /  div  > 
 <  /  div  >
```

 `v-if` is also an HTML attribute. Use it the same way you'd write the `hidden` attribute.

## Templates Are Not "Another Language"

 React's JSX is a JavaScript extension. You need a transpiler like Babel to use it.

Angular's templates have many proprietary constructs that drift far from HTML.

 Vue templates are HTML itself , with just a few attributes (`v-for`, `v-if`, `v-bind`) and `{{ }}`.

- If you can read HTML, you can read Vue templates

- They're visible as-is in browser DevTools

- HTML validators (mostly) accept them

 Templates being HTML — this is one of Vue's greatest strengths.

## Summary

- Vue templates are valid HTML with directives added

- {{ }} displays data

- v-for generates lists (written as HTML attributes)

- v-bind ( : ) binds data to attributes

- v-if / v-else for conditional display

- Template structure stays nearly identical to static HTML

- Still just a single index.html file

 [← Previous Bringing in Vue via CDN](/books/progressive-vue/02)

 [Next → Reactivity — From Static to Dynamic](/books/progressive-vue/04)

### Related

- [Signals and Signals. And Retained UI.](/en/posts/12) #javascript #oss #signals
- [Characterize Vue.js](/en/posts/07) #vue #javascript #oss
- [Vue.js is not Easy. It is Approachable.](/en/posts/06) #vue #javascript #language
- [What is Vue.js? It's just a language lol](/en/posts/05) #vue #javascript #language
- book [Progressive Vue](/en/books/progressive-vue) #vue #frontend #progressive
- chapter [First, HTML](/en/books/progressive-vue/01) #html #static

[← Back to book](/books/progressive-vue)

## Sitemap

- [Browse every page on wtrclred](https://wtrclred.vercel.app/sitemap.md)
