Emmet: What is Emmet? The Ultimate Shorthand Engine for…

Emmet is like the "auto-complete shorthand" for HTML and CSS — type a few characters, press Tab, and watch them instantly expand into full code.

1. What You'll Learn


2. A Front-End Developer's Real Story

(1) Pain Point: Hand-Coding HTML is Too Slow

Alice is a front-end developer, recently tasked with revamping her company's homepage. Every time she writes a navigation bar, she ends up typing over 30 lines of HTML by hand: a ul containing 5 li elements, each nesting an a tag. After the nav, there's a carousel with 6 div slides, each wrapping an image and text. By the end of the day, her fingers are sore — a 120-line HTML page took her a full 40 minutes. Then comes the CSS: margin: 10px 20px, padding: 5px, font-size: 16px — every line requires typing the full property name and semicolons. Alice thinks to herself: half my coding time is spent on "typing." Can't the editor just auto-complete this for me?

(2) Emmet's Solution

Emmet's answer is simple: compress common HTML/CSS patterns into abbreviations, and let the editor expand them into full code instantly. After learning Emmet, Alice writes that same 30-line navigation bar with just 16 characters:

TEXT 📖 参照専用
ul.nav>li.item*5>a{Link $}

She presses Tab, and the editor instantly expands it into 30 lines of complete HTML. Need 6 carousel slides? One line: div.slider>div.slide*6>img. Writing CSS? m10-20 auto-expands to margin: 10px 20px, fz16 becomes font-size: 16px. A page that used to take 40 minutes now takes Alice just 12.

(3) Benefits

Emmet delivers immediate, tangible gains for front-end developers: HTML writing speed increases 3-5x, CSS speed 2-3x. Mistakes like missing closing tags or mismatched attribute quotes — common when hand-coding — drop to nearly zero because Emmet generates everything automatically. More importantly, developers can focus on structure and style design instead of repetitive keystrokes. The learning investment is minimal: build your first impression in 5 minutes with this lesson, then spend 5-10 minutes per lesson on each of the remaining 17 to master one core concept at a time. After completing all 18 lessons, Alice writes an entire e-commerce homepage in under 30 minutes — down from 2 hours.


3. Core Definition of Emmet

Emmet (formerly Zen Coding) is an abbreviation expansion engine for HTML and CSS, first released by Sergey Chikuyonok in 2009 and officially renamed Emmet in 2013. It parses CSS-selector-like abbreviation strings and expands them in real time into complete HTML or CSS code, integrated into mainstream editors like VSCode, WebStorm, and Sublime Text.

Dimension Hand-Coding HTML Emmet Abbreviation
Speed ~8 min for a 30-line nav ~30 sec for a 30-line nav
Error Rate Missing closing tags, quote mismatches Auto-generated, near-zero errors
Learning Curve Intuitive, but repetitive Requires memorizing ~8 core operators
Reusability Rewrite every time Learn once, reuse forever
Editor Dependency Any editor Requires editor integration

Tip: Emmet is not a new programming language or framework. It is an editor plugin — at its core, it translates "abbreviation strings" into "complete code."


4. What Emmet Can Do

Emmet's capabilities fall into four categories: HTML abbreviations, CSS abbreviations, editor actions, and combined usage. Let's look at a few examples to build intuition.

(1) HTML Abbreviations

HTML abbreviations are Emmet's most-used feature. You type a CSS-selector-like abbreviation, press Tab, and it immediately expands into a complete HTML tag tree.

▶ Example: Basic Tag Abbreviation (Difficulty: ★)

Abbreviation:

HTML
ul.nav>li.item*5>a{Link $}

Expands to:

HTML
<ul class="nav">
  <li class="item"><a href="">Link 1</a></li>
  <li class="item"><a href="">Link 2</a></li>
  <li class="item"><a href="">Link 3</a></li>
  <li class="item"><a href="">Link 4</a></li>
  <li class="item"><a href="">Link 5</a></li>
</ul>

Output:

TEXT 📖 参照専用
The browser renders an unordered list with 5 linked list items. The `$` symbol is automatically replaced with an incrementing counter from 1 to 5.

(2) CSS Abbreviations

CSS abbreviations are Emmet's other core strength. Emmet borrows initials from CSS property names, compressing common properties and values into short strings.

▶ Example: CSS Abbreviation Preview (Difficulty: ★)

Abbreviation:

CSS
m10-20

Expands to:

CSS
margin: 10px 20px;

Abbreviation:

CSS
p10 fz16

Expands to:

CSS
padding: 10px;
font-size: 16px;

Output:

TEXT 📖 参照専用
`m` is the first letter of `margin`, `10-20` means 10px top/bottom and 20px left/right. `p` abbreviates `padding`, `fz` abbreviates `font-size`. Detailed CSS abbreviation rules are covered in lessons 11-13.

(3) Editor Actions

Emmet is not just "type abbreviation → expand code." It also provides a set of editor actions that make cursor navigation, code wrapping, and balance matching accessible with a single keystroke.

▶ Example: Expand Abbreviation Action (Difficulty: ★)

Open any .html file in VSCode, type div.container>ul>li*3, then:

BASH
# Step 1: Type the abbreviation
div.container>ul>li*3

# Step 2: Press Tab (default keybinding)
# Triggers the "Expand Abbreviation" action

# Step 3: The editor expands it to:
# <div class="container">
#   <ul>
#     <li></li>
#     <li></li>
#     <li></li>
#   </ul>
# </div>

# Step 4: The cursor jumps to the first <li></li>
# You can start typing immediately

Output:

TEXT 📖 参照専用
One line of abbreviation instantly becomes 6 lines of complete HTML, with the cursor positioned at the first editable spot — no manual clicking required. Detailed Actions usage is covered in lessons 14-16.

(4) Combined Demo

Combine HTML abbreviations + CSS abbreviations + editor actions, and you can write a complete login form in a single line. Here's a simplified example:

▶ Example: A Complete Login Form (Difficulty: ★★)

HTML Abbreviation:

HTML
form#login>(input[type=text name=user placeholder="Username"])+(input[type=password name=pwd placeholder="Password"])+(button.btn{Login})

Expands to:

HTML
<form id="login">
  <input type="text" name="user" placeholder="Username">
  <input type="password" name="pwd" placeholder="Password">
  <button class="btn">Login</button>
</form>

Matching CSS Abbreviation:

CSS
#login{w400 bg:#f5f5f5 p20}
.btn{bg:#3b82f6 c:#fff bd:none p10-20 cur:pointer}

Expands to:

CSS
#login {
  width: 400px;
  background: #f5f5f5;
  padding: 20px;
}
.btn {
  background: #3b82f6;
  color: #fff;
  border: none;
  padding: 10px 20px;
  cursor: pointer;
}

Output:

TEXT 📖 参照専用
The browser renders a 400px-wide login card with two input fields and a blue login button. From abbreviation input to a fully functional form takes just 2 steps (one HTML line + one CSS line), about 5 seconds.

5. Learning Path Preview

This tutorial has 18 lessons across 6 phases:

Phase Lessons Core Content Difficulty
Phase 1 - Getting Started 3 Emmet concepts, editor integration, basic tag abbreviations (current phase)
Phase 2 - HTML Abbreviations 5 Nesting >, climb-up ^, multiplication *, grouping (), ID/Class, attributes and numbering ★-★★
Phase 3 - Text & Advanced 2 Text content, Lorem Ipsum placeholders, implicit tag details ★-★★
Phase 4 - CSS Abbreviations 3 Unit inference, vendor prefixes, gradients and fuzzy matching ★★
Phase 5 - Actions 3 Expand, Wrap, Balance, Next Edit Point ★-★★
Phase 6 - Real-World Projects 2 Login page + responsive landing page ★★-★★★

After all 18 lessons, you'll be able to build complex HTML structures from a single abbreviation line, write common CSS in shorthand, and boost your editing speed 3-5x with 5 core actions.


❓ よくある質問

Q Is Emmet a programming language? Do I need to install it?
A Emmet is not a programming language; it's an editor plugin. VSCode, WebStorm, and other mainstream editors have it built in — no additional installation needed. Sublime Text and Atom require a plugin install (see lesson 2).
Q What's the difference between Emmet and code snippets?
A Code snippets are preset, fixed templates (e.g., html:5 expands to an HTML5 skeleton) and can't be parameterized. Emmet abbreviations are dynamically generated — they construct arbitrary structures from abbreviation strings in real time. Emmet is effectively a superset of snippets.
Q Do I need to learn HTML and CSS before learning Emmet?
A Strongly recommended. Emmet won't teach you what HTML/CSS are — it only accelerates how fast you write them. This tutorial assumes you already know HTML basics.
Q Is there a "standard" for Emmet abbreviations? Are they consistent across editors?
A Emmet syntax is unified and defined by the official documentation. All Emmet-compatible editors (VSCode, WebStorm, Sublime, etc.) produce identical expansion results. The only differences may be the default trigger key (Tab vs Ctrl+E) and CSS abbreviation coverage.

📖 まとめ


📝 練習問題

  1. Basic (Difficulty: ★): Open your preferred editor, create a new .html file, type div and press Tab. Record the result. Then try div.box and press Tab again. Compare the two expansions.
  2. Intermediate (Difficulty: ★★): Type the abbreviation ul>li*3>a{Item $} in your editor, press Tab, and observe the result. Then change *3 to *6 and re-expand. Record the differences.
  3. Challenge (Difficulty: ★★★): Use a single Emmet abbreviation to write the complete HTML structure of a homepage containing a navigation bar, a carousel, 3 cards, and a footer (CSS not required). Take 4 screenshots showing before and after expansion.
Web-Tutorial.com

Web-Tutorial 技術チーム

複数の開発者によって共同維持されているプログラミングチュートリアルプラットフォーム。各チュートリアルは専門分野の開発者が執筆・レビューしています。正確で信頼性の高いコンテンツを目指しています — 問題を見つけた場合はお知らせください。

100%