Emmet Cheat Sheet: Abbreviations for HTML and CSS
Checked against Emmet emmet npm package 2.4.11 (the engine VS Code uses); syntax from docs.emmet.io on 28 November 2026. Each section links to the official docs it was checked against.
This sheet is for anyone typing HTML or CSS in an editor with Emmet, which VS Code includes out of the box. Every expansion marked as tested was produced by the emmet npm package 2.4.11, the latest release on 28 Nov 2026, run in a scratch folder. Syntax rules come from docs.emmet.io and the VS Code Emmet page.
When to use what
Learn four operators first: > for a child, + for a sibling, * to repeat and . for a class. That covers most of what you type in a day. Grouping with parentheses is the next step up, because it stops you climbing back with ^, which gets hard to read past one level.
Keep abbreviations short. Emmet is fastest for the skeleton of a list, a nav or a table; typing a 60-character abbreviation for a whole page is slower than writing the HTML and harder to fix when one character is off. Also remember that a space ends the abbreviation, so ul > li will not expand the way you expect.
In VS Code, abbreviations show up in the suggestion list. If you would rather press Tab, set emmet.triggerExpansionOnTab to true. In React files Emmet writes className instead of class, which we confirmed with the package's JSX mode. If you paste HTML from elsewhere instead, our HTML to JSX converter handles the attribute renames, the HTML formatter tidies the result, and the CSS to Tailwind tool helps if your team writes utility classes rather than CSS.
A space stops parsing, so write abbreviations without spaces between operators.
div>ul>liChild: nest each element inside the previous one
div+p+bqSibling: three elements side by side; bq expands to blockquote
div+div>p>span+em^bqClimb-up: ^ moves bq up one level, next to the p
ul>li*3Multiplication: repeat an element three times
div>(header>ul>li*2>a)+footer>pGrouping: build a subtree, then continue as a sibling of the group
form>(label+input)*2+button:s{Send}Repeat a group: two label and input pairs, then a submit button
div#header+div.page.mainID with #, several classes chained with .
td[title="Hello world!" colspan=3]Custom attributes in brackets; quotes only needed for values with spaces
a{Click me}Text content in braces; a gets an empty href by default
p>{Click }+a{here}+{ to continue}Mix bare text and elements inside one parent
nav>ul>li*3>a[href=#]{Item $}Repeated links with numbered text: Item 1, Item 2, Item 3
ul>li.item$*3Classes item1, item2, item3
ul>li.item$$$*2Zero-padded numbers: item001, item002
ul>li.item$@-*3Count down: item3, item2, item1
ul>li.item$@3*3Start counting at 3: item3, item4, item5
ul.nav>li.nav-item*3>a.nav-link[href=/page-$]{Page $}Number attributes and text in the same repeat
Implicit names depend on the parent: div by default, span inside inline elements, li in lists, tr and td in tables, option in selects.
.wrap>.contentBare classes become div elements
em>.infoInside an inline element the implicit tag is span
ul>.item*2Inside a list the implicit tag is li
table>.row>.colInside a table: tr with class row, then td with class col
select>.optInside a select the implicit tag is option
!HTML5 document skeleton with charset, viewport and title
link:cssStylesheet link pointing at style.css
input:emailEmail input with empty name and id
btn:sExpands to <button type="submit"></button>
lorem5Five words of placeholder text
Integers default to px and decimals to em. Unit aliases: p is %, e is em, x is ex.
m10Expands to margin: 10px;
m10-20Two values: margin: 10px 20px;
m-10--20Negative values: margin: -10px -20px;
m1.5Decimal gets em: margin: 1.5em;
w100pPercent alias: width: 100%;
m10p30e5xMixed units: margin: 10% 30em 5ex;
c#3Short hex expands: color: #333;
bd5#0sBorder shorthand with a colour: border: 5px #000 solid;
lh2Unitless property: line-height: 2;
p10!Add !important: padding: 10px !important;
df / jcc / aicFlexbox quick trio: display: flex, justify-content: center, align-items: center
op.5Opacity without a unit: opacity: 0.5;
"emmet.triggerExpansionOnTab": trueExpand with Tab; Tab still indents when the text is not an abbreviation
"emmet.includeLanguages": { "javascript": "javascriptreact" }Turn on Emmet in plain .js files as JSX
div.card>p.title in a .jsx fileExpands with className instead of class (checked with the package's JSX mode)
Emmet: Wrap with AbbreviationCommand Palette action that wraps selected text in the abbreviation you type
div#page|cVS Code filter that adds comments after elements with an id or class
The core emmet package rejects |c; the filter is applied by the editor integration.
"emmet.showExpandedAbbreviation": "never"Hide Emmet entries from the suggestion list
Worked example: Build a navigation list with numbered links in one line
Say you need a nav with three items, each with a link to a numbered page. One abbreviation does it:
ul.nav>li.nav-item*3>a.nav-link[href=/page-$]{Page $}
The emmet 2.4.11 package expanded it to:
<ul class="nav">
<li class="nav-item"><a href="/page-1" class="nav-link">Page 1</a></li>
<li class="nav-item"><a href="/page-2" class="nav-link">Page 2</a></li>
<li class="nav-item"><a href="/page-3" class="nav-link">Page 3</a></li>
</ul>
Read it left to right. ul.nav is the parent, >li.nav-item*3 creates three children, and >a.nav-link puts one link in each. The $ is replaced with the repeat counter of the nearest multiplied element, in both the href attribute and the {Page $} text. Notice that Emmet writes the href before class in the output even though you typed the class first; attribute order in the result follows Emmet's own rules, which is harmless. Indentation uses tabs by default, so set your editor's formatting if your project uses spaces. If you wanted the counter to run backwards, $@- would give Page 3, Page 2, Page 1.
Common mistakes
Putting spaces around operators, as in
ul > li*3.A space stops Emmet parsing, so only the last word expands. Write
ul>li*3with no spaces.Chaining several
^to climb out of deep nesting.Use parentheses to group the subtree instead.
(header>nav>a)+mainis easier to read and edit thanheader>nav>a^^main.Expecting
$to count when there is no*on the element or an ancestor.The counter comes from multiplication. Add
*Nto the element you want repeated.Typing
m10and wondering why you gotmargin: 10pxwhen you wanted em.Integers default to px. Add the alias, as in
m10e, or use a decimal value, which defaults to em.Assuming Tab expands abbreviations in VS Code out of the box.
By default you pick the expansion from the suggestion list. Set
emmet.triggerExpansionOnTabto true if you want Tab.
Related cheat sheets
Sources
- https://docs.emmet.io/abbreviations/syntax/
- https://docs.emmet.io/abbreviations/implicit-names/
- https://docs.emmet.io/css-abbreviations/
- https://code.visualstudio.com/docs/languages/emmet
- https://www.npmjs.com/package/emmet
How we research: where our facts come from, how often we re-check them, and why no one can pay for a review or a verdict.