Skip to main content

Command Palette

Search for a command to run...

Emmet for HTML: A Beginner's Guide to Writing Faster Markup

Published
5 min read

Introduction

Have you ever found yourself typing the same HTML tags over and over again? Opening tags, closing tags, attributes, indentation—it all adds up to a lot of keystrokes. What if you could write HTML in a fraction of the time?

That's exactly what Emmet does. It's like a superpower for web developers that transforms simple abbreviations into complete HTML structures instantly.

What is Emmet?

Emmet is a toolkit that helps you write HTML and CSS faster using shorthand abbreviations. Think of it as a shortcut language that expands into full code.

Instead of typing:

<div class="container">
    <ul>
        <li></li>
        <li></li>
        <li></li>
    </ul>
</div>

You type this:

div.container>ul>li*3

Why Emmet is Useful for HTML Beginners

As a beginner, you might wonder why speed matters when you're still learning. Here's why Emmet is actually perfect for beginners:

→ Reduces repetitive typing: Less time typing means more time learning concepts and building projects.
Teaches HTML structure: Emmet's syntax mirrors HTML's hierarchical nature, helping you understand parent-child relationships better.
Prevents typos: Since Emmet generates the code, you won't forget closing tags or make syntax errors.
Keeps you in flow: When you're coding and ideas are flowing, you don't want to break concentration typing out every angle bracket.
Industry standard: Most professional developers use Emmet, so learning it early gives you a head start.

How Emmet Works Inside Code Editors

Emmet comes built into most modern code editors. You don't need to install anything extra in popular editors like:

  • Visual Studio Code (VS Code)

  • Sublime Text

  • Atom

  • WebStorm

  • Brackets

Here's how it works:

  1. You type an Emmet abbreviation

  2. You press Tab (or sometimes Enter)

  3. Emmet expands the abbreviation into full HTML code

The editor recognizes Emmet syntax automatically when you're working in HTML files.

Basic Emmet Syntax and Abbreviations

Let's start with the fundamentals. Emmet uses simple symbols to represent HTML structure:

Element Names

Just type the element name:

div

Expands to:

<div></div>

Child Elements: >

The greater-than symbol creates a child element:

div>p

Expands to:

<div>
    <p></p>
</div>

Sibling Elements: +

The plus symbol creates elements at the same level:

div+p+span

Expands to:

<div></div>
<p></p>
<span></span>

Grouping: ()

Parentheses group elements together:

div>(header>h1)+footer

Expands to:

<div>
    <header>
        <h1></h1>
    </header>
    <footer></footer>
</div>

Climb Up: ^

The caret symbol moves up one level in the hierarchy:

div>p>span^p

Expands to:

<div>
    <p><span></span></p>
    <p></p>
</div>

Creating HTML Elements Using Emmet

Let's look at creating common HTML elements

Creating a Header

header>h1+nav>ul>li*3

Becomes:

<header>
    <h1></h1>
    <nav>
        <ul>
            <li></li>
            <li></li>
            <li></li>
        </ul>
    </nav>
</header>

Creating a Form

form>input:text+input:email+button:submit

Becomes:

<form action="">
    <input type="text" name="" id="">
    <input type="email" name="" id="">
    <button type="submit"></button>
</form>

Notice how Emmet intelligently adds the correct type attributes!

Adding Classes, IDs, and Attributes

Emmet makes it super easy to add classes and IDs, similar to CSS selectors.

Classes: .

div.container

Expands to:

<div class="container"></div>

Multiple classes:

div.card.featured.highlight

Expands to:

<div class="card featured highlight"></div>

IDs: #

div#main

Expands to:

<div id="main"></div>

Combining Classes and IDs

div#header.container.fluid

Expands to:

<div id="header" class="container fluid"></div>

Custom Attributes: []

a[href="https://example.com" target="_blank"]

Expands to:

<a href="https://example.com" target="_blank"></a>

Text Content: {}

p{Hello World}

Expands to:

<p>Hello World</p>

Complex example:

a[href="#"]{Click Here}

Expands to:

<a href="#">Click Here</a>

Creating Nested Elements

Nesting is where Emmet really shines. You can create complex HTML structures with just one line

Simple Nesting

article>header>h2+p

Becomes:

<article>
    <header>
        <h2></h2>
        <p></p>
    </header>
</article>

Complex Nesting Example

div.wrapper>div.container>header>nav>ul>li*4>a

Becomes:

<div class="wrapper">
    <div class="container">
        <header>
            <nav>
                <ul>
                    <li><a href=""></a></li>
                    <li><a href=""></a></li>
                    <li><a href=""></a></li>
                    <li><a href=""></a></li>
                </ul>
            </nav>
        </header>
    </div>
</div>

Building a Card Component

div.card>img+div.card-body>h3.card-title+p.card-text+a.btn

Becomes:

<div class="card">
    <img src="" alt="">
    <div class="card-body">
        <h3 class="card-title"></h3>
        <p class="card-text"></p>
        <a href="" class="btn"></a>
    </div>
</div>

Repeating Elements Using Multiplication

The multiplication operator * is incredibly useful for creating multiple similar elements

Basic Repetition

ul>li*5

Expands to:

<ul>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
</ul>

Numbered Items: $

Add auto-incrementing numbers with the dollar sign:

ul>li.item$*3

Expands to:

<ul>
    <li class="item1"></li>
    <li class="item2"></li>
    <li class="item3"></li>
</ul>

Multiple Digits: $$

ul>li.item$$*3

Expands to:

<ul>
    <li class="item01"></li>
    <li class="item02"></li>
    <li class="item03"></li>
</ul>

Starting from a Specific Number: $@N

ul>li.item$@3*3

Expands to:

<ul>
    <li class="item3"></li>
    <li class="item4"></li>
    <li class="item5"></li>
</ul>

Reverse Numbering: $@-

ul>li.item$@-*3

Expands to:

<ul>
    <li class="item3"></li>
    <li class="item2"></li>
    <li class="item1"></li>
</ul>

Generating Full HTML Boilerplate with Emmet

One of the most useful Emmet shortcuts creates a complete HTML5 boilerplate. Just type:

!

Or:

html:5

Press Tab, and you get:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

</body>
</html>

This single character saves you from typing or copying and pasting the entire HTML structure every time you start a new project!

Practical Examples and Workflow

Let's put it all together with some real-world examples

Example 1: Blog Post Layout

article>header>h1{My Blog Post}+p.meta{Published on January 30, 2026}^^section>p*3>lorem^^footer>a{Read More}

This creates a complete blog post structure with placeholder text.

Example 2: Navigation Menu

nav.navbar>ul.nav-list>li.nav-item*4>a.nav-link{Menu Item}

Instant navigation structure with classes ready for styling.

div.gallery>div.gallery-item*6>img+p.caption

Creates a gallery grid with image placeholders and captions.

Example 4: Form with Validation

form>div.form-group*3>label+input:text

Quick form structure with grouped inputs.

Conclusion

Emmet is an incredibly powerful tool that makes writing HTML faster and more enjoyable. While it might seem overwhelming at first, start with the basics:

  • Element names

  • Classes and IDs

  • Nesting with >

  • Siblings with +

  • Multiplication with *

Master these core concepts, and you'll already be writing HTML much faster. As you grow more comfortable, gradually incorporate advanced features like numbering, grouping, and custom attributes.

Remember, Emmet is a tool to enhance your productivity, not a requirement. Use it when it helps, and don't worry about using every feature. The goal is to write better HTML faster, not to memorize every Emmet trick.