Back to Blogs
Developer Tools

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

P
Punyansh Singla
January 26, 20264 min read
EmmetHTMLCSSProductivityWeb DevelopmentVS CodeDeveloper Tools

What is Emmet?

Emmet is a time-saving tool for web developers that lets you write shortcuts that convert automatically into full blocks of HTML or CSS code. For example, if you have to write boilerplate code, without Emmet you would write it in the following steps:

  1. first <html></html>
  2. then <body></body> inside <html></html>
  3. then you will add <head></head> in <body></body>
  4. then <title></title> in head

Then you will start writing the main code, but with Emmet you will just write ! and press enter and boom—you see this in your code editor:

html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
</html>

Why Emmet is useful for HTML beginners

Emmet helps beginners write code faster and with less effort. It removes unnecessary typing and lets you focus on learning how HTML and CSS actually work. As a beginner, you should focus on learning concepts more than manual typing. Emmet allows you to use shortcuts instead of writing the same long, repetitive code over and over again. Emmet increases your speed of writing HTML and CSS code.

How Emmet works inside the code editor

When we type any Emmet shortcut in a code editor like Sublime or VS Code, the Emmet engine runs in the background, parses the shortcut in real-time, and converts the shortcut to complete, long code. It happens very fast, in just milliseconds.

Basic Emmet syntax and abbreviations

  1. ! (exclamation mark)
html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
</html>
  1. . (dot)
html
<div class=""></div>
  1. .classname (dot + classname)
html
<div class="classname"></div>
  1. elementname (like p)
html
<p></p>
  1. > (child) like div>p
html
<div>
    <p></p>
</div>
  1. + (sibling) like h1+p
html
<h1></h1>
<p></p>
  1. * (multiplication) like li*5
html
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
  1. $*number (numbering) like li.item$*5
html
<li class="item1"></li>
<li class="item2"></li>
<li class="item3"></li>
<li class="item4"></li>
<li class="item5"></li>
  1. {} (content) like p{hello by punyansh singla}
html
<p>hello by punyansh singla</p>

ID and classnames using Emmet

  1. elementname#idname like p#paragraph
html
<p id="paragraph"></p>
  1. elementname.classname like p.long-para
html
<p class="long-para"></p>

Attributes using Emmet

  1. input[attribute][attribute] like input[type=number][min=3]
html
<input type="number" min="3">

We can combine selectors in one line

  1. nav>ul>li*3>a[href=#]{Link $}
html
<nav>
    <ul>
        <li><a href="#">Link 1</a></li>
        <li><a href="#">Link 2</a></li>
        <li><a href="#">Link 3</a></li>
    </ul>
</nav>
  1. div.footer>span{2026}+a[href=#]{Privacy}+a[href=#]{Terms}
html
<div class="footer">
    <span>2026</span>
    <a href="#">Privacy</a>
    <a href="#">Terms</a>
</div>

Enjoyed this article?

Share it with your network

Punyansh's AssistantOnline
AI

Hey there! 👋 I'm Punyansh's AI assistant. Feel free to ask me anything about his skills, projects, or experience!

20 LEFT