Skip to main content

Command Palette

Search for a command to run...

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

Published
2 min read

If you have ever written a full webpage from scratch, you know that HTML can feel... repetitive. Typing out <div></div>, <p></p>, and <li></li> over and over again is not just slow; it’s a distraction from actually building your site.

What if you could type a simple "shorthand" code, hit one key, and watch it explode into dozens of lines of perfect HTML? That is exactly what Emmet does.

What is Emmet?

Emmet is a plugin (built into most modern code editors like VS Code) that acts like a "translator." You type a small abbreviation, and Emmet translates it into full HTML markup.

It is essentially the autocorrect for web developers, but much more predictable and powerful.

1. The Instant Boilerplate

Every HTML file needs the same starting code: the <html> tags, the <head>, the <meta> tags, and the <body>. Instead of copying and pasting this from an old project, just type:

!

Hit Tab (or Enter), and Emmet generates the entire standard HTML5 skeleton for you instantly.

2. Creating Basic Elements

To create a tag, you don't need the < or > symbols. Just type the name of the tag.

  • Type: pTab

  • Result: <p></p>

  • Type: h1Tab

  • Result: <h1></h1>

3. Adding Classes and IDs

Remember how we use . for classes and # for IDs in CSS? Emmet uses that exact same logic to build your elements.

  • For a Class: div.container<div class="container"></div>

  • For an ID: header#main-nav<header id="main-nav"></header>

  • Combined: p.intro#first<p class="intro" id="first"></p>

4. Nesting Elements (The Family Tree)

This is where the real speed comes in. You can use the > symbol to say "put this tag inside that tag."

  • Type: div>p

5. Multiplication (The List Killer)

Need a navigation bar with five list items? Don't copy-paste. Use the * symbol.

  • Type: ul>li*5

  • Result:

    HTML

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

6. Adding Text Content

You can even tell Emmet what text should go inside the tags using curly braces {}.

  • Type: button{Click Me}

  • Result: <button>Click Me</button>

Summary Cheat Sheet

GoalSymbolExample
ElementNamediv
Class..title
ID##main
Child>ul>li
Sibling+h1+p
Multiplication*li*3
Text{}p{Hello}