What is Emmet?

Emmet is a powerful toolkit and text editor plugin that allows developers to write HTML, CSS, and other code faster by expanding simple abbreviations into full code snippets.

How It Works

Emmet uses a concise syntax inspired by CSS selectors. You type an abbreviation and trigger expansion (often with Tab or Enter), and Emmet generates the corresponding code structure.

Basic Examples

AbbreviationExpanded Result
li*3
<ul>
<li></li>
<li></li>
<li></li>
</ul>
div.container p
<div class="container">
<p></p>
</div>
h1#title
<h1 id="title"></h1>

Advanced Features

  • Multiplication: *n repeats elements (e.g., li*5 creates 5 list items).
  • Grouping: Parentheses () group elements (e.g., (header+main)).
  • Attributes: Square brackets [] add attributes (e.g., input[type="text"]).
  • CSS Support: Expands CSS properties (e.g., m10 becomes margin: 10px;).

Practical Example

Typing this abbreviation:

div#wrapper>header+main>article.post*2>h2{Post $}+p

Expands to:

<div id="wrapper">
<header></header>
<main>
  <article class="post">
    <h2>Post 1</h2>
    <p></p>
  </article>
  <article class="post">
    <h2>Post 2</h2>
    <p></p>
  </article>
</main>
</div>

Benefits

  • Speeds up coding workflow significantly
  • Reduces repetitive typing
  • Supported in editors like VS Code, Sublime Text, and JetBrains IDEs
  • Customizable with user-defined snippets

Note: Emmet is built into many modern editors (e.g., VS Code) by default, but you can install it as a plugin for others. It’s especially useful for React developers writing JSX.