Skip to content

Menu

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>li

Child: nest each element inside the previous one

div+p+bq

Sibling: three elements side by side; bq expands to blockquote

div+div>p>span+em^bq

Climb-up: ^ moves bq up one level, next to the p

ul>li*3

Multiplication: repeat an element three times

div>(header>ul>li*2>a)+footer>p

Grouping: 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.main

ID 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$*3

Classes item1, item2, item3

ul>li.item$$$*2

Zero-padded numbers: item001, item002

ul>li.item$@-*3

Count down: item3, item2, item1

ul>li.item$@3*3

Start 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>.content

Bare classes become div elements

em>.info

Inside an inline element the implicit tag is span

ul>.item*2

Inside a list the implicit tag is li

table>.row>.col

Inside a table: tr with class row, then td with class col

select>.opt

Inside a select the implicit tag is option

!

HTML5 document skeleton with charset, viewport and title

link:css

Stylesheet link pointing at style.css

input:email

Email input with empty name and id

btn:s

Expands to <button type="submit"></button>

lorem5

Five words of placeholder text

Integers default to px and decimals to em. Unit aliases: p is %, e is em, x is ex.

m10

Expands to margin: 10px;

m10-20

Two values: margin: 10px 20px;

m-10--20

Negative values: margin: -10px -20px;

m1.5

Decimal gets em: margin: 1.5em;

w100p

Percent alias: width: 100%;

m10p30e5x

Mixed units: margin: 10% 30em 5ex;

c#3

Short hex expands: color: #333;

bd5#0s

Border shorthand with a colour: border: 5px #000 solid;

lh2

Unitless property: line-height: 2;

p10!

Add !important: padding: 10px !important;

df / jcc / aic

Flexbox quick trio: display: flex, justify-content: center, align-items: center

op.5

Opacity without a unit: opacity: 0.5;

"emmet.triggerExpansionOnTab": true

Expand with Tab; Tab still indents when the text is not an abbreviation

From the docs, not run by us
"emmet.includeLanguages": { "javascript": "javascriptreact" }

Turn on Emmet in plain .js files as JSX

From the docs, not run by us
div.card>p.title in a .jsx file

Expands with className instead of class (checked with the package's JSX mode)

Emmet: Wrap with Abbreviation

Command Palette action that wraps selected text in the abbreviation you type

From the docs, not run by us
div#page|c

VS 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.

From the docs, not run by us
"emmet.showExpandedAbbreviation": "never"

Hide Emmet entries from the suggestion list

From the docs, not run by us

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*3 with no spaces.

  • Chaining several ^ to climb out of deep nesting.

    Use parentheses to group the subtree instead. (header>nav>a)+main is easier to read and edit than header>nav>a^^main.

  • Expecting $ to count when there is no * on the element or an ancestor.

    The counter comes from multiplication. Add *N to the element you want repeated.

  • Typing m10 and wondering why you got margin: 10px when 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.triggerExpansionOnTab to true if you want Tab.