Emmet 缩写
在 HTML/CSS 中用 Tab 展开 Emmet:完整 HTML 语法与 CSS 属性词典,以及 lorem、pixem、pixcm、piximg-*、pixreset、pixfont、pixicon、pixcdn 等自定义指令。
什么是 Emmet?
Emmet 让你用简短缩写快速生成 HTML 标签、CSS 属性或占位文本。HTML 与 CSS 编辑器已内置,无需额外配置。编辑器工具栏的键盘图标打开速查弹窗后,可在 Emmet 页签搜索本文的缩写词典(输入 max 即可找到 maw → max-width)。
如何展开
在 HTML 或 CSS 面板光标处输入缩写后按 Tab 展开。输入过程中可按 Ctrl+Shift+Space(Mac 为 Control+Shift+Space)打开 Emmet 补全。HTML 编辑器中 lorem、pixem、pixcm、piximg-*、pixfont、pixicon-* 与 pixcdn 支持 Tab 展开;CSS 编辑器中可用 pixreset、pixbody、pixc、pixfont,以及 Font Awesome 等纯 CSS 的 pixicon-*;pixcdn 与 Lucide / Feather 仍在 HTML/JS。
常用 HTML 缩写
可组合标签、class、ID、属性与乘法(*N)。展开后 Tab 会在可编辑位置(如 class 名、链接文字)间跳转。完整运算符与常用片段见下一节。
ul>li.item$*3
| 缩写 | 含义 | 展开示例 |
|---|---|---|
| div | 空 div | <div></div> |
| div.container | 带 class 的 div | <div class="container"></div> |
| ul>li*3 | 3 项无序列表 | <ul><li></li><li></li><li></li></ul> |
| table>tr*3>td*4 | 3 行 × 4 列表格 | <table>…</table> |
| a[href=#] | 带 href 的链接 | <a href="#"></a> |
| div>p+lorem | div 内含段落 + lorem 文本 | <div><p>…</p></div> |
HTML 语法与片段
任意单词都能展开成标签(foo → <foo></foo>)。下面是嵌套运算符、属性写法,以及编辑器内置的常用片段。缩写中间不能有空格。
| 缩写 | 含义 | 展开示例 |
|---|---|---|
| > | 子元素 | div>ul>li |
| + | 同级元素 | div+p+bq |
| ^ | 回到上一层 | div>p>span^bq |
| *N | 重复 N 次 | ul>li*5 |
| () | 分组 | div>(header+footer) |
| .class #id | class 与 id | div.page#hero |
| [attr] | 自定义属性 | a[href=# target=_blank] |
| $ | 重复项序号 | ul>li.item$*3 |
| {} | 元素文本 | a{Click me} |
文档与资源
| 缩写 | 展开示例 |
|---|---|
| ! / html:5 | <!DOCTYPE html>…html>head+body |
| doc | html>head+body |
| link:css | <link rel="stylesheet" href="style.css"> |
| script:src | <script src=""></script> |
| meta:vp | <meta name="viewport" content="width=device-width…"> |
链接
| 缩写 | 展开示例 |
|---|---|
| a | <a href=""></a> |
| a:blank | <a href="http://" target="_blank" rel="noopener noreferrer"> |
| a:mail | <a href="mailto:"></a> |
| a:tel | <a href="tel:+"></a> |
图片与媒体
| 缩写 | 展开示例 |
|---|---|
| img | <img src="" alt=""> |
| img:s / img:srcset | <img srcset="" src="" alt=""> |
| pic | <picture></picture> |
| video | <video src=""></video> |
| audio | <audio src=""></audio> |
表单
| 缩写 | 展开示例 |
|---|---|
| form | <form action=""></form> |
| input:text / input:t | <input type="text"> |
| input:email | <input type="email"> |
| input:c / input:checkbox | <input type="checkbox"> |
| btn | <button></button> |
| btn:s / button:submit | <button type="submit"> |
| label | <label for=""></label> |
| select | <select name="" id=""></select> |
语义标签别名
| 缩写 | 展开示例 |
|---|---|
| hdr | <header></header> |
| ftr | <footer></footer> |
| sect | <section></section> |
| art | <article></article> |
| mn | <main></main> |
| bq | <blockquote></blockquote> |
| fig | <figure></figure> |
| figc | <figcaption></figcaption> |
| dlg | <dialog></dialog> |
| str | <strong></strong> |
CSS 缩写
CSS 面板中 Emmet 以相同方式展开属性缩写。未写单位时整数默认 px、小数默认 em。HTML 与 CSS 行首输入 // 会转为注释(HTML 为 <!-- -->,CSS 为 /* */);CSS 输入 /* 会自动补上关闭符;pixc 再按 Tab 也可在 CSS 插入注释。完整属性对照见文末词典。
| 缩写 | 含义 | 展开示例 |
|---|---|---|
| t10 | top: 10px | top: 10px; |
| m10 | margin: 10px | margin: 10px; |
| p20 | padding: 20px | padding: 20px; |
| w100p | width: 100% | width: 100%; |
| bdrs5 | border-radius: 5px | border-radius: 5px; |
| bdrs50p | border-radius: 50% | border-radius: 50%; |
| d:f | display: flex | display: flex; |
| pos:a | position: absolute | position: absolute; |
CSS 写法规则
属性缩写后直接跟数值,不必写冒号:t10 → top: 10px。多个值用连字符分隔;后一个负值用两个连字符。单位别名写在数字后面。也可用属性:关键字(d:f)或末尾 ! 表示 !important。
单位别名
| 别名 | 单位 |
|---|---|
| p | % |
| e | em |
| x | ex |
数值展开示例
| 缩写 | 展开示例 |
|---|---|
| t10 | top: 10px; |
| m10 | margin: 10px; |
| m10-20 | margin: 10px 20px; |
| m-10--20 | margin: -10px -20px; |
| m1.5 | margin: 1.5em; |
| w100p | width: 100%; |
| m10p30e5x | margin: 10% 30em 5ex; |
| bdrs50p | border-radius: 50%; |
| c#3 | color: #333; |
| bd5#0s | border: 5px #000 solid; |
| fw400 | font-weight: 400; |
| d:f | display: flex; |
| pos:a | position: absolute; |
| p! | padding: !important; |
CSS 属性词典
下列缩写与官方 Emmet CSS snippets 对齐。找到属性后可直接加数值,例如 bdrs50p → border-radius: 50%。单角圆角是 bdtlrs / bdtrrs / bdblrs / bdbrrs(bdrst 是 border-right-style,不是圆角)。可用浏览器查找(⌘F / Ctrl+F)。
@ 规则
| 缩写 | 属性 |
|---|---|
| @f | @font-face |
| @ff | @font-face (full src) |
| @i / @import | @import url() |
| @kf | @keyframes |
| @m / @media | @media |
定位
| 缩写 | 属性 |
|---|---|
| pos | position |
| t | top |
| r | right |
| b | bottom |
| l | left |
| z | z-index |
| i | inset |
| ib | inset-block |
| ii | inset-inline |
| ibs | inset-block-start |
| ibe | inset-block-end |
| iis | inset-inline-start |
| iie | inset-inline-end |
显示、弹性与网格
| 缩写 | 属性 |
|---|---|
| d | display |
| fl | float |
| fx | flex |
| fxb | flex-basis |
| fxd | flex-direction |
| fxf | flex-flow |
| fxg | flex-grow |
| fxsh | flex-shrink |
| fxw | flex-wrap |
| ac | align-content |
| ai | align-items |
| as | align-self |
| jc | justify-content |
| ji | justify-items |
| js | justify-self |
| ord | order |
| g | gap |
| cg | column-gap |
| rg | row-gap |
| gd | grid |
| gt | grid-template |
| gtc | grid-template-columns |
| gtr | grid-template-rows |
| gta | grid-template-areas |
| gg | grid-gap |
| gcg | grid-column-gap |
| grg | grid-row-gap |
| gac | grid-auto-columns |
| gar | grid-auto-rows |
| gaf | grid-auto-flow |
| gc | grid-column |
| gcs | grid-column-start |
| gce | grid-column-end |
| gr | grid-row |
| grs | grid-row-start |
| gre | grid-row-end |
| ga | grid-area |
盒模型
| 缩写 | 属性 |
|---|---|
| m | margin |
| mt | margin-top |
| mr | margin-right |
| mb | margin-bottom |
| ml | margin-left |
| mbl | margin-block |
| mi | margin-inline |
| mbs | margin-block-start |
| mbe | margin-block-end |
| mis | margin-inline-start |
| mie | margin-inline-end |
| p | padding |
| pt | padding-top |
| pr | padding-right |
| pb | padding-bottom |
| pl | padding-left |
| pbl | padding-block |
| pi | padding-inline |
| pbs | padding-block-start |
| pbe | padding-block-end |
| pis | padding-inline-start |
| pie | padding-inline-end |
| w / wid | width |
| h | height |
| maw | max-width |
| mah | max-height |
| miw | min-width |
| mih | min-height |
| mab | max-block-size |
| mai | max-inline-size |
| mib | min-block-size |
| mii | min-inline-size |
| bs | block-size |
| is | inline-size |
| bxsz | box-sizing |
| bxsh | box-shadow |
| ar | aspect-ratio |
边框与圆角
| 缩写 | 属性 |
|---|---|
| bd | border |
| bdc | border-color |
| bds | border-style |
| bdw | border-width |
| bdrs | border-radius |
| bdtlrs | border-top-left-radius |
| bdtrrs | border-top-right-radius |
| bdblrs | border-bottom-left-radius |
| bdbrrs | border-bottom-right-radius |
| bdt | border-top |
| bdr | border-right |
| bdb | border-bottom |
| bdl | border-left |
| bdtc | border-top-color |
| bdrc | border-right-color |
| bdbc | border-bottom-color |
| bdlc | border-left-color |
| bdts | border-top-style |
| bdrst | border-right-style |
| bdbs | border-bottom-style |
| bdls | border-left-style |
| bdtw | border-top-width |
| bdrw | border-right-width |
| bdbw | border-bottom-width |
| bdlw | border-left-width |
| bdcl | border-collapse |
| bdsp | border-spacing |
| bdi | border-image |
| bdbl | border-block |
| bdin | border-inline |
| bbs / bdbls | border-block-start |
| bbe / bdble | border-block-end |
| bdis | border-inline-start |
| bdie | border-inline-end |
背景
| 缩写 | 属性 |
|---|---|
| bg | background |
| bg:n | background: none |
| bgc | background-color |
| bgi | background-image |
| bgr | background-repeat |
| bgp | background-position |
| bgpx | background-position-x |
| bgpy | background-position-y |
| bgsz | background-size |
| bgcp | background-clip |
| bgo | background-origin |
| bga | background-attachment |
| lg | background-image: linear-gradient() |
文字
| 缩写 | 属性 |
|---|---|
| c | color |
| cr | color: rgb() |
| cra | color: rgba() |
| f | font |
| ff | font-family |
| fsz | font-size |
| fw | font-weight |
| fs | font-style |
| fv | font-variant |
| fst | font-stretch |
| fsza | font-size-adjust |
| fd | font-display |
| fvs | font-variation-settings |
| lh | line-height |
| ta | text-align |
| tal | text-align-last |
| td | text-decoration |
| tt | text-transform |
| ti | text-indent |
| tj | text-justify |
| lts | letter-spacing |
| tsh | text-shadow |
| tov | text-overflow |
| tw | text-wrap |
| va | vertical-align |
| whs | white-space |
| wob | word-break |
| wow | word-wrap |
| wos | word-spacing |
| te | text-emphasis |
溢出、透明与轮廓
| 缩写 | 属性 |
|---|---|
| ov | overflow |
| ovx | overflow-x |
| ovy | overflow-y |
| v | visibility |
| op / opa | opacity |
| cur | cursor |
| cl | clear |
| ol | outline |
| olc | outline-color |
| ols | outline-style |
| olw | outline-width |
| olo | outline-offset |
| us | user-select |
| ap | appearance |
| bfv | backface-visibility |
| rsz | resize |
变换、过渡与动画
| 缩写 | 属性 |
|---|---|
| trf | transform |
| trfo | transform-origin |
| trfs | transform-style |
| trs | transition |
| trsde | transition-delay |
| trsdu | transition-duration |
| trsp | transition-property |
| trstf | transition-timing-function |
| anim | animation |
| animn | animation-name |
| animdur | animation-duration |
| animdel | animation-delay |
| animdir | animation-direction |
| animtf | animation-timing-function |
| animfm | animation-fill-mode |
| animic | animation-iteration-count |
| animps | animation-play-state |
列表、表格与多栏
| 缩写 | 属性 |
|---|---|
| lis | list-style |
| lisi | list-style-image |
| lisp | list-style-position |
| list | list-style-type |
| tbl | table-layout |
| cnt | content |
| colm | columns |
| colmc | column-count |
| colmf | column-fill |
| colmg | column-gap |
| colmr | column-rule |
| colmrc | column-rule-color |
| colmrs | column-rule-style |
| colmrw | column-rule-width |
| colms | column-span |
| colmw | column-width |
其他
| 缩写 | 属性 |
|---|---|
| cm | /* comment */ |
| cp | clip |
| coi | counter-increment |
| cor | counter-reset |
| cps | caption-side |
| ec | empty-cells |
| ori | orientation |
| orp | orphans |
| wido | widows |
| wm | writing-mode |
| q | quotes |
| sb | scroll-behavior |
| spbs | scroll-padding-block-start |
| spbe | scroll-padding-block-end |
| spis | scroll-padding-inline-start |
| spie | scroll-padding-inline-end |
| mar | max-resolution |
| mir | min-resolution |
| zom | zoom |
| fft | font-family: Times |
| ffa | font-family: Arial |
| ffv | font-family: Verdana |
| fsm | font-smoothing |
| fef | font-effect |
| fem | font-emphasize |
| femp | font-emphasize-position |
| fems | font-emphasize-style |
| bgbk | background-break |
| bdbi | border-bottom-image |
| bdbk | border-break |
| bdbli | border-bottom-left-image |
| bdbri | border-bottom-right-image |
| bdci | border-corner-image |
| bdf | border-fit |
| bdlen | border-length |
| bdli | border-left-image |
| bdri | border-right-image |
| bdti | border-top-image |
| bdtli | border-top-left-image |
| bdtri | border-top-right-image |
| ovs | overflow-style |
| pgba | page-break-after |
| pgbb | page-break-before |
| pgbi | page-break-inside |
| qen | quotes (EN) |
| qru | quotes (RU) |
| th | text-height |
| to | text-outline |
| tr | text-replace |
| whsc | white-space-collapse |
占位文本
HTML 与 CSS 中有多种占位与辅助工具:Emmet lorem 生成经典拉丁假文;pixem 与 pixcm 插入可读英文或简体中文 UI 文案;piximg-* 从 Picsum、pravatar、randomuser.me 或 DiceBear 插入随机占位图或头像;pixfont 插入 CDN Fonts 或 Google Fonts 样式表;pixicon-* 可直插常用图标 CDN。
| 工具 | 缩写示例 | 语言 | 风格 | 计量 |
|---|---|---|---|---|
| Emmet lorem | lorem / lorem30 | 拉丁文 | 经典 Lorem ipsum | 单词 |
| pixem | pixem / pixemN | 英文 | 可读 UI 文案 | 词 |
| pixcm | pixcm / pixcmN | 简体中文 | 可读 UI 文案 | 字 |
| piximg-picsum | piximg-picsum / piximg-picsum1200x600 | HTML / CSS | Picsum 随机摄影图 | 像素(宽×高) |
| piximg-avatar | piximg-avatar / piximg-avatar128 | — | pravatar 真人头像 | 像素(裸缩写无路径边长;或用 64/128/256 预设) |
| piximg-randomuser | piximg-randomuser / piximg-randomuser128 | — | randomuser.me 真人肖像 | 像素(映射 thumb/med/large) |
| piximg-dicebear | piximg-dicebear / piximg-dicebear-lorelei | — | DiceBear 插画头像 | 像素(正方形边长) |
| pixfont | pixfont / pixfont-inter | — | CDN Fonts 网页字体 | 字体族 |
Emmet lorem
输入 lorem 缩写后按 Tab 展开。字数按单词计数。
| 缩写 | 含义 | 展开示例 |
|---|---|---|
| lorem | 默认段落(约 30 词) | — |
| lorem30 | 指定 N 个单词的段落 | 30 |
| lorem*3 | N 段正文(每段默认长度) | 3 |
pixem、pixcm、piximg-*、pixreset、pixfont 与 pixicon(自定义指令)
pixcm 插入简体中文 UI 占位文本,按字计数;pixem 插入英文 UI 文案,按词计数;piximg-picsum / piximg-avatar / piximg-randomuser / piximg-dicebear 插入 Picsum 随机图、pravatar 真人头像、randomuser.me 真人肖像或 DiceBear 插画头像。CSS 面板可用 pixreset 插入通配符最小清零,或 pixreset-all 插入完整 reset;两者都不含伪元素,以免盖掉图标字体。pixbody 插入居中铺满视口的 body,光标停在 background-color 后方便手写颜色。pixc 插入块注释并把光标停在中间。pixfont 打开网页字体搜索弹窗(CDN Fonts / Google Fonts);pixfont-<slug> 仍直插 CDN Fonts 预设;pixicon-<slug> 直插常用图标 CDN(如 Font Awesome、Lucide)。文案类支持长度、多段与 -t(标题)等字段后缀;piximg-* 支持尺寸与 -url(仅 URL)。完整缩写表见自定义指令专题。
| 缩写 | 含义 | 展开示例 |
|---|---|---|
| piximg-picsum | Picsum 占位图(随机宽×高,完整 img 标签) | <img src="https://picsum.photos/…" alt=""> |
| piximg-picsum1200x600 | Picsum 占位图(1200×600,完整 img 标签) | <img src="https://picsum.photos/seed/pix42/1200/600" alt=""> |
| piximg-avatar | pravatar 真人头像(默认尺寸,路径无边长) | <img src="https://i.pravatar.cc/?img=12" alt=""> |
| piximg-randomuser128 | randomuser.me 真人肖像(128×128) | <img src="https://randomuser.me/api/portraits/med/men/42.jpg" alt=""> |
| piximg-dicebear | DiceBear 插画头像(avataaars) | <img src="https://api.dicebear.com/7.x/avataaars/png?…" alt=""> |
| piximg-picsum-url | 仅 Picsum 图片 URL(随机宽×高) | https://picsum.photos/… |
| pixcm | 中文正文(约 30 字) | — |
| pixcmN | 指定 N 字的中文正文 | 20 |
| pixem | 英文正文(约 30 词) | — |
| pixemN | 指定 N 词的英文正文 | 20 |
| pixcm-t / pixem-name | 字段型占位(标题、姓名、电话等) | — |
| pixreset | CSS 清零(最小通配符) | * { margin: 0; … } |
| pixreset-all | CSS 清零(完整 reset) | — |
| pixbody | 居中 body(光标停在 background-color) | body { min-height: 100vh; … } |
| pixc | CSS 块注释(光标停在开闭定界符中间) | /* */ |
| pixfont | 搜索网页字体(打开弹窗) | 打开网页字体搜索弹窗 |
| pixfont-inter | 插入 CDN Fonts 预设字体 | <link href="https://fonts.cdnfonts.com/css/inter" rel="stylesheet"> |