Jay Abhani
Senior Web Development Instructor at almaBetter
Boost your web development speed with this Emmet cheat sheet, covering essential HTML and CSS abbreviations for Visual Studio Code with examples and shortcuts
Emmet is a powerful toolkit for web developers that significantly boosts productivity by allowing them to write HTML and CSS faster using abbreviations. It is widely supported in Visual Studio Code (VS Code), Sublime Text, Atom, and other modern code editors.
This Emmet cheat sheet serves as a quick reference guide for developers who want to master Emmet abbreviations, Emmet HTML cheat sheet, CSS Emmet cheat sheet, and how to use Emmet in VS Code efficiently.
Emmet is a shortcut system for writing HTML and CSS code efficiently. It expands short abbreviations into full-fledged HTML and CSS structures, reducing the time required to write repetitive code.
Emmet is pre-installed in VS Code, but you may need to enable it for specific file types.
Emmet works automatically in .html and .css files in VS Code.
If you need Emmet in a different file (e.g., JavaScript or PHP files), follow these steps:
{
"emmet.includeLanguages": {
"javascript": "javascriptreact",
"php": "html"
}
}
Now, Emmet will work in JavaScript and PHP files as well.
The Emmet abbreviation cheat sheet for HTML helps speed up code writing using shortcuts.
!
Press Tab or Enter after typing !, and Emmet will generate a full HTML boilerplate:
<!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>
Emmet Code | Expands To |
---|---|
h1{Hello World} | <h1>Hello World</h1> |
p{This is a paragraph} | <p>This is a paragraph</p> |
a{Click me} | <a href="">Click me</a> |
ul>li*3 creates an unordered list with 3 list items.
<ul>
<li></li>
<li></li>
<li></li>
</ul>
nav>ul>li*3>a{Link $} creates a nav bar with three links.
<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>
Emmet Code | Expands To |
---|---|
div#main | <div id="main"></div> |
div.container | <div class="container"></div> |
section.hero.banner | <section class="hero banner"></section> |
The CSS Emmet cheat sheet speeds up writing CSS rules.
Emmet Code | Expands To |
---|---|
w100 | width: 100px; |
h50 | height: 50px; |
m20 | margin: 20px; |
p10 | padding: 10px; |
Emmet Code | Expands To |
---|---|
fs16 | font-size: 16px; |
fw700 | font-weight: 700; |
c#333 | color: #333; |
bg#f4f4f4 | background-color: #f4f4f4; |
Emmet Code | Expands To |
---|---|
d:f | display: flex; |
fd:c | flex-direction: column; |
ai:c | align-items: center; |
jc:sb | justify-content: space-between; |
Creates multiple elements at once.
div*5
Expands to:
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
$ helps auto-increment numbers inside elements.
ul>li.item$*3
Expands to:
<ul>
<li class="item1"></li>
<li class="item2"></li>
<li class="item3"></li>
</ul>
(div>h2{Title})+(div>p{Description})
Expands to:
<div>
<h2>Title</h2>
</div>
<div>
<p>Description</p>
</div>
You can customize Emmet settings in VS Code:
By default, Tab expands Emmet abbreviations, but you can change it to Enter:
You can create custom Emmet abbreviations by modifying VS Code settings:
{
"emmet.variables": {
"lang": "en"
},
"emmet.syntaxProfiles": {
"html": {
"tag_case": "lower"
}
}
}
Here are some common interview questions related to Emmet:
Q. What is Emmet, and why is it used?
Emmet is a shortcut system for writing HTML and CSS faster.
Q. How do you create an Emmet abbreviation for a navigation bar?
nav>ul>li*3>a{Link $}
Q. Can you use Emmet in JavaScript files in VS Code?
Yes, by enabling "emmet.includeLanguages" in settings.json.
Q. How does $ work in Emmet?
$ is used for auto-incrementing numbers in class names, IDs, or text.
This Emmet cheat sheet serves as a quick reference guide for writing HTML and CSS efficiently in Visual Studio Code. Mastering Emmet abbreviations will speed up development and boost productivity.
More Cheat Sheets and Top Picks