Skip to main content

Command Palette

Search for a command to run...

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

Emmet Tricks for HTML

Published
3 min read
Emmet for HTML: A Beginner’s Guide to Writing Faster Markup
K

I am a problem solver and a full-stack developer. I love to write and share my knowledge. My wish is to learn and help others learn at the same time. Hoping to make a difference in the tech world.

Introduction to Emmet

What is Emmet?

Emmet is a powerful tool built for developers to write faster HTML with the help of tricks and abbreviations

How is Emmet useful of Beginners?

Emmet is useful especially for HTML beginners as they can focus on writing semantic HTML without having to memorize boilerplate code.

How it works in code editors?

Emmet can be used by writing abbreviations inside code editors. This avoids the hassle of writing boilerplate HTML code.

Emmet is like a “shortcut” language for HTML

Basic Emmet syntax and abbreviations

HTML Element Abbreviation

Any HTML tag can be entered for fast scaffolding:

p     → <p></p>
div   → <div></div> 
table → <table></table>

Emmet expands them into complete elements.

Child > and Sibling + Combinators

Combine tags with > and + to make complex markup:

nav>ul>li    → <nav><ul><li></li></ul></nav>
div+p+span →  
  <div></div>
  <p></p>
  <span></span>

These builds nested and sibling structures rapidly.

Multiplication * Operator

Repeat elements by appending *n to multiply:

ul>li*5 →
  <ul>
    <li></li>
    <li></li> 
    <li></li>
    <li></li>
    <li></li>
  </ul>

No need to copy-paste!

Content Insertion {}

Insert text content with curly braces:

p{Hello world} → <p>Hello world</p>

Numbering $

Sequentially number items using $:

ul>li.item$*5 →
  <ul>
    <li class="item1"></li>
    <li class="item2"></li>
    <li class="item3"></li> 
    <li class="item4"></li>
    <li class="item5"></li>
  </ul>

There are many more Core Emmet Features to speed up writing markup.

Handy HTML Abbreviations

Here is a handy reference table of some common Emmet HTML shortcuts:

AbbreviationExpansion
! or html:5HTML5 doctype
a<a href=""></a>
link<link rel="stylesheet" href="">
script<script src=""></script>
img<img src="" alt="">
inp<input type="text">
btn<button></button>
fqWraps content in <figure><figcaption></figcaption></figure>
tableCreates table scaffold
ol>li*3Numbered list with 3 items
ul>li*5Bulleted list with 5 items
lorem or lipsumInserts lorem ipsum text

See the full HTML cheat sheet here.

Let‘s go over some CSS helper abbreviations too!

Handy CSS Abbreviations

Emmet comes packed with tons of CSS abbreviations out of the box:

AbbreviationExpansion
posposition: ;
zmz-index: ;
fw400font-weight: 400;
ta-ctext-align: center;
m10margin: 10px;
pd20padding: 20px;
bd1s#f00border: 1px solid #f00;
bgc#123background-color: #123;
And many more

You can instantly type these shortcuts instead of declaring the full CSS each time!

Other Resources: