# Emmet Quick Reference

*HTML abbreviations, nesting, attributes, CSS shortcuts*

> Source: Emmet Documentation (emmet.io) · MIT

## HTML Abbreviations

### Element Shortcuts

| Command | Description |
|---------|-------------|
| `div` | Create <div></div> |
| `p` | Create <p></p> |
| `h1` | Create <h1></h1> |
| `a` | Create <a href=""></a> |
| `img` | Create <img src="" alt=""> |
| `input` | Create <input type="text"> |
| `btn` | Create <button></button> |
| `link:css` | Link tag for CSS stylesheet |

### HTML Boilerplate

```
!    → full HTML5 boilerplate
doc  → HTML5 doctype only
```

### Implicit Tags

| Command | Description |
|---------|-------------|
| `.class` | Resolves to <div class="class"> |
| `ul>.item` | Child resolves to <li class="item"> |
| `table>.row` | Child resolves to <tr class="row"> |
| `select>.opt` | Child resolves to <option class="opt"> |

## Nesting

### Nesting Operators

| Command | Description |
|---------|-------------|
| `>` | Child element |
| `+` | Sibling element |
| `^` | Climb up one level |
| `^^` | Climb up two levels |

### Nesting Examples

```
div>ul>li       → nested child elements
div+p+footer    → sibling elements
div>p>span^h2   → climb up: h2 is sibling of p
div>p>span^^h2  → climb up twice: h2 sibling of div
```

## Grouping

### Parentheses Grouping

```
div>(header>nav)+main+footer
→ groups header>nav as a unit
(div>h2+p)*3
→ repeat grouped structure 3 times
```

### Complex Layout

```
.container>(header>h1+nav>ul>li*3)+main+footer
→ full page layout skeleton
```

## Multiplication

### Repeat Operator

| Command | Description |
|---------|-------------|
| `li*5` | Create 5 <li> elements |
| `div>p*3` | Div with 3 child paragraphs |
| `ul>li*4>a` | List with 4 items, each containing a link |
| `tr>td*4` | Table row with 4 cells |

### Multiplication Examples

```
ul>li.item*5           → 5 list items with class
table>tr*3>td*4        → 3x4 table grid
.row>.col*3>p{Content} → 3-column row with text
```

## Numbering

### Item Numbering ($)

| Command | Description |
|---------|-------------|
| `$` | Sequential number (1, 2, 3...) |
| `$$` | Zero-padded two digits (01, 02...) |
| `$$$` | Zero-padded three digits (001, 002...) |
| `$@3` | Start numbering from 3 |
| `$@-` | Reverse numbering (descending) |
| `$@-3` | Reverse numbering starting from 3 |

### Numbering Examples

```
li.item$*3    → item1, item2, item3
li.item$$*3   → item01, item02, item03
li.item$@3*3  → item3, item4, item5
```

## Attributes

### ID and Class

| Command | Description |
|---------|-------------|
| `#id` | Add id attribute: <div id="id"> |
| `.class` | Add class: <div class="class"> |
| `.c1.c2` | Multiple classes: class="c1 c2" |
| `#main.container` | ID + class combined |

### Custom Attributes

```
td[colspan=2]        → <td colspan="2">
a[href=#]{Click}     → <a href="#">Click</a>
input[type=email placeholder=Email]
div[data-id=$]*3     → data-id="1", "2", "3"
```

## Text

### Text Content ({})

| Command | Description |
|---------|-------------|
| `p{Hello}` | <p>Hello</p> |
| `a{Click me}` | <a href="">Click me</a> |
| `p{Item $}*3` | Item 1, Item 2, Item 3 |

### Text with Nesting

```
p>{Click }+a{here}+{ to continue}
→ <p>Click <a href="">here</a> to continue</p>
ul>li{Item $}*4
→ list with numbered items
```

## CSS Abbreviations

### Box Model

| Command | Description |
|---------|-------------|
| `m10` | margin: 10px; |
| `m10-20` | margin: 10px 20px; |
| `p10` | padding: 10px; |
| `w100` | width: 100px; |
| `w100p` | width: 100%; |
| `h50` | height: 50px; |

### Display & Position

| Command | Description |
|---------|-------------|
| `d:f` | display: flex; |
| `d:g` | display: grid; |
| `d:n` | display: none; |
| `d:b` | display: block; |
| `pos:r` | position: relative; |
| `pos:a` | position: absolute; |

### Flexbox

| Command | Description |
|---------|-------------|
| `jc:c` | justify-content: center; |
| `jc:sb` | justify-content: space-between; |
| `ai:c` | align-items: center; |
| `fxd:c` | flex-direction: column; |
| `fw:w` | flex-wrap: wrap; |

### Typography & Colors

| Command | Description |
|---------|-------------|
| `fz14` | font-size: 14px; |
| `fw:b` | font-weight: bold; |
| `ta:c` | text-align: center; |
| `c:#333` | color: #333; |
| `bgc:#fff` | background-color: #fff; |
