Emmet Crash Course
Emmit is a code snippets manager for VS Code. It is used to create HTML code faster. Emmit is a must-have tool for any web developer. In VS Code, Emmit is enabled by default. It works only after you have created a new HTML file.
Learn the shortcuts and just press the tab or enter key to get the code you want.
Some common Emmit shortcuts
!- Inserts a<!DOCTYPE html>tagh1- Inserts a<h1>tagh2- Inserts a<h2>tagp- Inserts a<p>tagimg- Inserts an<img>taga- Inserts an<a>tagul- Inserts an<ul>tagul>li- Inserts a<li>tag inside an<ul>tagul>li>a- Inserts an<a>tag inside a<li>tag inside an<ul>tagul>li*3- Inserts 3<li>tags inside an<ul>tagdiv- Inserts a<div>tagdiv>p- Inserts a<p>tag inside a<div>tagdiv>p*3- Inserts 3<p>tags inside a<div>tag
ID and Class
#- Inserts anidattribute.- Inserts aclassattribute
Example:
-
#my-id- Inserts anidattribute with the valuemy-id -
.my-class- Inserts aclassattribute with the valuemy-class -
div>(header>ul>li*2>a)+footer>p1- expands into<div><header><ul><li><a href=""></a></li><li><a href=""></a></li></ul></header><footer><p></p></footer></div>
Grouping
div>(header>ul>li*2>a)+footer>p- Inserts a<div>tag with a<header>tag inside it, a<ul>tag inside it, and 2<li>tags inside the<ul>tag. Then it inserts an<a>tag inside each<li>tag. Finally it inserts a<footer>tag and a<p>tag inside it.
Yep, it can go little bit crazy. But you don’t have to worry about it. Rarely you will need to use it.
CSS shortcuts
style- Inserts a<style>tagpos- Inserts apositionpropertypos:absolute- Inserts apositionproperty with the valueabsolutebgc- Inserts abackground-colorpropertybgc:red- Inserts abackground-colorproperty with the valueredma- Inserts amargin:autoproperty
Conclusion
Emmit is a must-have tool for any web developer. BUT this does not mean you have to learn every single shortcut. You can use Emmit to create HTML code faster. NO ONE remembers all the shortcuts. We use then mostly by trial and error, and learning them as we go.
Start your journey with ChaiCode
All of our courses are available on chaicode.com. Feel free to check them out.