Emmet
EMMET
The essential toolkit for web-developers
Introduction
Emmet is a productivity toolkit for web developers that uses expressions to generate HTML snippets.
Installation
Normally, installation for Emmet should be a straight-forward process from the package-manager, as most of the modern text editors support Emmet. If you have difficulty setting up emmet with your editor and wish to check Emmet is supported by your favourite editor or not, you can check it from here. Emmet Installation instructions
Usage
You can use Emmet in two ways:
Tab Expand Way: Type your emmet code and press
Tab
keyInteractive Method: Press
alt + ctrl + Enter
and start typing your expressions. This should automatically generate HTML snippets on the fly.
This cheatsheet will assume that you press Tab
after each expressions.
HTML
Generating HTML 5 DOCTYPE
html:5
Will generate
Child items
Child items are created using >
ul>li>p
Sibling Items
Sibling items are created using +
html>head+body
Multiplication
Items can be multiplied by *
ul>li*5
Grouping
Items can be grouped together using ()
table>(tr>th*5)+tr>t*5
Class and ID
Class and Id in Emmet can be done using .
and #
div.heading
div#heading
ID and Class can also be combined together
div#heading.center
Adding Content inside tags
Contents inside tags can be added using {}
h1{Emmet is awesome}+h2{Every front end developers should use this}+p{This is paragraph}*2
Attributes inside HTML tags
Attributes can be added using []
a[href=https://?google.com data-toggle=something target=_blank]
Numbering
Numbering can be done using $
You can use this inside tag or contents.
h${This is so awesome $}*6
Use @-
to reverse the Numbering
img[src=image$$@-.jpg]*5
To start the numbering from specific number, use this way
img[src=emmet$@100.jpg]*5
Tips
Use
:
to expand known abbreviations
input:date
form:post
link:css
Building Navbar
.navbar>ul>li*3>a[href=#]{Item $@-}
CSS
Emmet works surprisingly well with css as well.
f:l
You can also use any options n/r/l
pos:aΒ
Also use any options, pos:a/r/f
d:n/bΒ/f/Βi/ib
d:ib
You can use
m
for margin andp
for padding followed by direction
mr
-> margin-right
pr
-> padding-right
@f
will result in
You can also use these shorthands
Shorthand | Description |
---|---|
z | z-index |
w | width |
h | height |
fz | font-size |
ff | font-family |
fw | font-weight |
@lh | line-height |
maw | max-width |
mah | max-height |
miw | min-width |
mih | min-width |
! | !important |
@f | font-face |
@op | opacity |
@lh | line-height |
@op | opacity |
Last updated