# Referensi Cepat Emmet

*Singkatan HTML, nesting, atribut, shortcut CSS*

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

## Singkatan HTML

### Shortcut Elemen

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

### Boilerplate HTML

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

### Tag Implisit

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

## Nesting

### Operator Nesting

| Command | Description |
|---------|-------------|
| `>` | Elemen child |
| `+` | Elemen sibling |
| `^` | Naik satu level |
| `^^` | Naik dua level |

### Contoh Nesting

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

## Pengelompokan

### Pengelompokan dengan Tanda Kurung

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

### Layout Kompleks

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

## Perkalian

### Operator Repeat

| Command | Description |
|---------|-------------|
| `li*5` | Buat 5 elemen <li> |
| `div>p*3` | Div dengan 3 paragraf child |
| `ul>li*4>a` | List dengan 4 item, masing-masing berisi link |
| `tr>td*4` | Baris tabel dengan 4 sel |

### Contoh Perkalian

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

## Penomoran

### Penomoran Item ($)

| Command | Description |
|---------|-------------|
| `$` | Nomor berurutan (1, 2, 3...) |
| `$$` | Dua digit dengan nol (01, 02...) |
| `$$$` | Tiga digit dengan nol (001, 002...) |
| `$@3` | Mulai penomoran dari 3 |
| `$@-` | Penomoran terbalik (menurun) |
| `$@-3` | Penomoran terbalik mulai dari 3 |

### Contoh Penomoran

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

## Atribut

### ID dan Class

| Command | Description |
|---------|-------------|
| `#id` | Tambah atribut id: <div id="id"> |
| `.class` | Tambah class: <div class="class"> |
| `.c1.c2` | Beberapa class: class="c1 c2" |
| `#main.container` | ID + class digabung |

### Atribut Kustom

```
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"
```

## Teks

### Konten Teks ({})

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

### Teks dengan Nesting

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

## Singkatan CSS

### 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 & Posisi

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

### Tipografi & Warna

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