Emmit 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 anid
attribute.
- Inserts aclass
attribute
Example:
#my-id
- Inserts anid
attribute with the valuemy-id
.my-class
- Inserts aclass
attribute with the valuemy-class
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 aposition
propertypos:absolute
- Inserts aposition
property with the valueabsolute
bgc
- Inserts abackground-color
propertybgc:red
- Inserts abackground-color
property with the valuered
ma
- Inserts amargin:auto
property
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.