Emmet Documentation

Emmet — the essential toolkit for web-developers

Abbreviations

Abbreviations Syntax

Elements

You can use elements’ names like div or p to generate HTML tags. Emmet doesn’t have a predefined set of available tag names, you can write any word and transform it into a tag: div → <div></div>foo → <foo></foo> and so on.

Nesting operators

Child: >

Sibling: +

Climb-up: ^

div+div>p>span+em^bq
...outputs to
<div></div>
<div>
<p><span></span><em></em></p>
<blockquote></blockquote>
</div>

You can use as many ^ operators as you like, each operator will move one level up:

div+div>p>span+em^^^bq

...will output to

<div></div>
<div>
<p><span></span><em></em></p>
</div>
<blockquote></blockquote>

Multiplication: *

Grouping: ()

Parenthesises are used by Emmets’ power users for grouping subtrees in complex abbreviations:

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

...expands to

<div>
<header>
<ul>
<li><a href=""></a></li>
<li><a href=""></a></li>
</ul>
</header>
<footer>
<p></p>
</footer>
</div>

Attribute operators

ID and CLASS

div#header+div.page+div#footer.class1.class2.class3

Custom attributes

td[title="Hello world!" colspan=3]

Item numbering: $

ul>li.item$*5

Changing numbering base and direction

For example, to change direction, add @- after $:

ul>li.item$@-*5

…outputs to

<ul>
<li class="item5"></li>
<li class="item4"></li>
<li class="item3"></li>
<li class="item2"></li>
<li class="item1"></li>
</ul>

To change counter base value, add @N modifier to $:

ul>li.item$@3*5

…transforms to

<ul>
<li class="item3"></li>
<li class="item4"></li>
<li class="item5"></li>
<li class="item6"></li>
<li class="item7"></li>
</ul>

You can use these modifiers together:

ul>li.item$@-3*5

…is transformed to

<ul>
<li class="item7"></li>
<li class="item6"></li>
<li class="item5"></li>
<li class="item4"></li>
<li class="item3"></li>
</ul>

Text: {}

Notes on abbreviation formatting

For example, use spaces between elements and operators, like this:

(header > ul.nav > li*5) + footer

But it won’t work, because space is a stop symbol where Emmet stops abbreviation parsing.

Element types

In the abbreviations section of snippets.json you can also define aliases: a short-hands for commonly used abbreviations. Aliases can be used to define:

  • short names for long tag names;
  • referencing commonly used abbreviations.

In snippets.json file, you can find the following definitions:

...
"html": {
"abbreviations": {
"bq": "blockquote",
"ol+": "ol>li"
}
}

Implicit tag names

Here’s how it resolves the names for some parent elements:

  • li for ul and ol
  • tr for tabletbodythead and tfoot
  • td for tr
  • option for select and optgroup

Take a look at some abbreviations equivalents with implicit and explicit tag names:

.wrap>.content div.wrap>div.content
em>.info em>span.info
ul>.item*3 ul>li.item*3
table>#row$*4>[colspan=2] table>tr#row$*4>td[colspan=2]

“Lorem Ipsum” generator

1 ul.generic-list>lorem10.item*4

CSS Abbreviations

How it works?

First, it looks for a m10 snippet definition in snippets.json. If it’s found, it simply outputs it as a regular snippet. Otherwise, it extracts value from abbreviation.

When property part is found, resolver searches for the snippet definition in snippets.json. For an m part, it will find "m": "margin:|;" definition (| character is used as a caret position reference when the snippet is expanded).

Supplying values with units

By default, when you expand an abbreviation with integer value, Emmet outputs it with a px unit: m10 → margin: 10px;

If you’re expanding an abbreviation with a float value, it is outputted with an em unit: m1.5 → margin: 1.5em;

But you can explicitly provide the unit name, just by putting any alpha characters right after value: m1.5ex → margin: 1.5ex;m10foo → margin: 10foo;.

If you’re explicitly defining units, you don’t need to use hyphens to separate values anymore: m10ex20em → margin: 10ex 20em;m10ex-5 → margin: 10ex -5px;.

Value aliases

Emmet has a few aliases for commonly used values:

  • p → %
  • e → em
  • x → ex

You can use aliases instead of full units:

  • w100p → width: 100%
  • m10p30e5x → margin: 10% 30em 5ex

Color values

Emmet supports hex color values, like this: c#3 → color: #333;

The # sign is a value separator so you don’t need to use hyphen to separate it. For example, bd5#0s expands to border: 5px #000 solid: the # sign separates color from 5 and since s (alias to solid) is not a hexadecimal character, it can be used without - value separator.

You can write one, two, three or six characters as color value:

  • #1 → #111111
  • #e0 → #e0e0e0
  • #fc0 → #ffcc00

Unit-less properties

Some CSS properties are defined as unit-less, e.g. no unit suffix will be outputted: lh2 → line-height: 2;fw400 → font-weight: 400;.

These values are: 'z-indexline-heightopacity and font-weight but you can override them with css.unitlessProperties preferences.

!important modifier

p!+m10e!

...will produce

padding:  !important;
margin: 10em !important;

Vendor prefixes

How it works?

For example, for -bdrs abbreviation it will look for a bdrs definition. snippet.json has the following definition:

"bdrs": "border-radius:|;"

Add prefixed properties by default

Explicit vendor prefixed

-wm-trf

Emmet has the following one-letter prefixes:

  • wwebkit
  • mmoz
  • sms
  • oo

Gradients

lg( left, #fc0, 30%, red)
border-image:lg( left, #fc0, 30%, red)

...will produce

    background-image: -webkit-linear-gradient(left, #fc0, 30%, red);
background-image: -moz-linear-gradient(left, #fc0, 30%, red);
background-image: -o-linear-gradient(left, #fc0, 30%, red);
background-image: linear-gradient(to right, #fc0, 30%, red);
-webkit-border-image:-webkit-linear-gradient(left, #fc0, 30%, red);
-moz-border-image:-moz-linear-gradient(left, #fc0, 30%, red);
-o-border-image:-o-linear-gradient(left, #fc0, 30%, red);
border-image:linear-gradient(to right, #fc0, 30%, red);

Fallback value

In preferences, you can enable css.gradient.fallback option to produce a fallback background-color CSS property whenever a gradient definition for background-* CSS property is expanded.

Fuzzy search

For example, instead of writing ov:h (overflow: hidden;) abbreviation, you can write ov-hovh or even oh.

Remember that you can always create your own snippets or redefine existing ones to fine-tune fuzzy search experience.

Emmet Documentation ( Abbreviations+CSS Abbreviations )的更多相关文章

  1. Emmet Documentation

    src:http://docs.emmet.io/cheat-sheet/ Emmet Documentation Syntax   Child: > nav>ul>li <n ...

  2. 转载: Emmet:HTML/CSS代码快速编写神器

    Emmet:HTML/CSS代码快速编写神器 因为文章严禁转载,那本着做一个遵纪守法的好公民,我就不转载了,把链接放下面,方便查阅. http://www.iteye.com/news/27580

  3. 【03】emmet系列之CSS语法

    [01]emmet系列之基础介绍 [02]emmet系列之HTML语法 [03]emmet系列之CSS语法 [04]emmet系列之编辑器 [05]emmet系列之各种缩写   单位: 有几个常用值别 ...

  4. Emmet:HTML/CSS代码快速编写神器

    本文来源:http://www.iteye.com/news/27580    ,还可参考:http://www.w3cplus.com/tools/emmet-cheat-sheet.html Em ...

  5. Emmet快速编写CSS样式

    基本的CSS样式编写时,很多样式只需输入首字母即可得到不带属性值的CSS样式,像上面说到的margin. 1.而对于一些带有特定的属性值的CSS样式,只需输入CSS标签与属性值的首字母就可以,比如: ...

  6. Emmet:HTML/CSS代码快速编写神器(转)

    Emmet的前身是大名鼎鼎的Zen coding,如果你从事Web前端开发的话,对该插件一定不会陌生.它使用仿CSS选择器的语法来生成代码,大大提高了HTML/CSS代码编写的速度,比如下面的演示: ...

  7. Sublime Text 3插件之Emmet:HTML/CSS代码快速编写神器

    一.快速编写HTML代码 1.  初始化 HTML文档需要包含一些固定的标签,比如<html>.<head>.<body>等,现在你只需要1秒钟就可以输入这些标签. ...

  8. Emmet:HTML/CSS代码快速编写神器教程

    Emmet的前身是大名鼎鼎的Zen coding,如果你从事Web前端开发的话,对该插件一定不会陌生.它使用仿CSS选择器的语法来生成代码,大大提高了HTML/CSS代码编写的速度,比如下面的演示: ...

  9. (webstorm的css编写插件)Emmet:HTML/CSS代码快速编写神器

    Emmet的前身是大名鼎鼎的Zen coding,如果你从事Web前端开发的话,对该插件一定不会陌生.它使用仿CSS选择器的语法来生成代码,大大提高了HTML/CSS代码编写的速度,比如下面的演示: ...

  10. Emmet:HTML/CSS代码快速编写神器--20150422

    Emmet的前身是大名鼎鼎的Zen coding,如果你从事Web前端开发的话,对该插件一定不会陌生.它使用仿CSS选择器的语法来生成代码,大大提高了HTML/CSS代码编写的速度,比如下面的演示: ...

随机推荐

  1. 程序员应具备的PS基本技能(一):PS2017基本框架使用

    若该文为原创文章,未经允许不得转载原博主博客地址:https://blog.csdn.net/qq21497936原博主博客导航:https://blog.csdn.net/qq21497936/ar ...

  2. 使用Xilinx MIG验证硬件DDR设计

    1     导读 MIG 是xilinx的memory控制器,功能强大,接口易用.当硬件设计在设计对应的DDR接口时,最好先用MIG去配置一遍DDR的管脚约束.电平约束,从而避免硬件设计好了,实际却无 ...

  3. 第141篇:微信小程序wx.request接口报错(errno: 600001, errMsg: "request:fail -2:net::ERR_FAILED")

    好家伙,   来看看报错 报错如下:   请求发送部分,代码如下: uni.request({ url: self.serverUrl + "/getRealName", meth ...

  4. Vue 之 new vue({})与export default {} 的区别

    刚入门 vue 的,可能会有这样的困惑:什么时候用new vue({}),什么时候用export default {} 呢? 比如,我们在用 cli 创建项目时 在 main.js 入口里面用的时ne ...

  5. 【Azure 媒体服务】记录使用Java调用Media Service API时候遇见的一些问题

    问题一:java.lang.IllegalArgumentException: Parameter this.client.subscriptionId() is required and canno ...

  6. 压测中TPS上不去的几种原因及分析?

    1. 服务器资源限制:服务器的硬件资源(如 CPU.内存.磁盘)可能不足以处理大量的请求.在高负载情况下,服务器可能无法及时响应所有的请求,导致 TPS 上不去.解决方法可以考虑升级硬件资源或通过负载 ...

  7. 第18章_MySQL8其它新特性

    # 目录: https://www.cnblogs.com/xjwhaha/p/15844178.html 1. MySQL8新特性概述 MySQL从5.7版本直接跳跃发布了8.0版本,可见这是一个令 ...

  8. Mutillidae品台上使用sqlmap注入测试

    Mutillidae是一个开放源码的提供安全渗透测试的Web应用程序, Mutillidae可以安装在Linux.windows xp.windows 7等平台上.下载及安装说明文档详见:mutill ...

  9. 适用于AbpBoilerplate的阿里云腾讯云Sms短信服务

    Sms 适用于AbpBoilerplate的短信服务(Short Message Service,SMS)模块,通过简单配置即可使用,仅更改一处代码即可切换短信服务提供商. Aliyun.Sms由阿里 ...

  10. 图数据库基准测试 LDBC SNB 系列讲解:Schema 和数据生成的机制

    LDBC(Linked Data Benchmark Council)Social Network Benchmark,简称 LDBC SNB,是一种针对社交网络场景的评估图数据库性能的基准测试. L ...