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

What is Emmet?

Emmet is a free plugin built into almost every modern code editor (like VS Code). Think of it as Auto-correct for developers, but much smarter. You type a short abbreviation, hit the Tab key, and Emmet expands it into full HTML markup.

Why Use It?

  • Speed: You can write a whole website structure in seconds.

  • Accuracy: No more forgotten closing tags or typos in class names.

  • Focus: You spend more time thinking about structure and less time typing brackets.


1. The Basics: Elements, Classes, and IDs

Emmet uses a syntax very similar to CSS selectors. If you know how to target a class in CSS, you already know Emmet!

  • Element: Type the tag name (e.g., p) → <p></p>

  • Class: Use a dot (e.g., .container) → <div class="container"></div>

  • ID: Use a hash (e.g., #main) → <div id="main"></div>


2. Nesting: Creating Relationships

You can build entire "family trees" of HTML elements in one line using symbols:

  • Child (>): Places an element inside another.

    • div>p<div><p></p></div>
  • Sibling (+): Places an element next to another.

    • h1+p<h1></h1><p></p>
  • Climb Up (^): Moves back up one level in the nesting.


3. Multiplication: Handling Repetitive Tasks

Need a list with five items? Don't copy-paste! Use the asterisk (*) to multiply elements.

  • Abbreviation: ul>li*5

  • Result:

    HTML

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

4. The "Magic" Boilerplate

Every HTML file needs the same basic setup (head, body, meta tags). Instead of memorizing it or copy-pasting from an old project, just type an exclamation mark and hit Tab.

  • Abbreviation: !

  • Result: Generates the full HTML5 skeleton instantly.


Emmet Cheat Sheet for Beginners

Goal

Emmet Shortcut

Resulting HTML

Simple Tag

header

<header></header>

Class on Div

.card

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

Specific Tag + Class

span.price

<span class="price"></span>

Nested List

nav>ul>li

Nav containing UL containing LI

Multiple Items

li*3

Three LI tags

Dummy Text

lorem10

10 words of "Lorem Ipsum" filler