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.
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.
Abbreviation | Expanded 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> |
*n
repeats elements (e.g., li*5
creates 5 list items).()
group elements (e.g., (header+main)
).[]
add attributes (e.g., input[type="text"]
).m10
becomes margin: 10px;
).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>
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.