emmet语法

使用方法

emmet的使用方法也非常简单,以sublime text为例,直接在编辑器中输入HTML或CSS的代码的缩写,然后按tab键就可以拓展为完整的代码片段。(如果与已有的快捷键有冲突的话,可以自行在编辑器中将拓展键设为其他快捷键)

语法:

后代:>

缩写:nav>ul>li

<nav>
    <ul>
        <li></li>
    </ul>
</nav>

兄弟:+

缩写:div+p+bq

<div></div>
<p></p>
<blockquote></blockquote>

上级:^

缩写:div+div>p>span+em^bq

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

缩写:div+div>p>span+em^^bq

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

分组:()

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

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

缩写:(div>dl>(dt+dd)*3)+footer>p

<div>
    <dl>
        <dt></dt>
        <dd></dd>
        <dt></dt>
        <dd></dd>
        <dt></dt>
        <dd></dd>
    </dl>
</div>
<footer>
    <p></p>
</footer>

乘法:*

缩写:ul>li*5

<ul>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
</ul>

自增符号:$

缩写:ul>li.item$*5

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

缩写:h$[title=item$]{Header $}*3

<h1 title="item1">Header 1</h1>
<h2 title="item2">Header 2</h2>
<h3 title="item3">Header 3</h3>

缩写:ul>li.item$$$*5

<ul>
    <li class="item001"></li>
    <li class="item002"></li>
    <li class="item003"></li>
    <li class="item004"></li>
    <li class="item005"></li>
</ul>

缩写:ul>[email protected]*5

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

缩写:ul>[email protected]*5

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

ID和类属性

缩写:#header

<div id="header"></div>

缩写:.title

<div class="title"></div>

缩写:form#search.wide

<form id="search" class="wide"></form>

缩写:p.class1.class2.class3

<p class="class1 class2 class3"></p>

自定义属性

缩写:p[title="Hello world"]

<p title="Hello world"></p>

缩写:td[rowspan=2 colspan=3 title]

<td rowspan="2" colspan="3" title=""></td>

缩写:[a=‘value1‘ b="value2"]

<div a="value1" b="value2"></div>

文本:{}

缩写:a{Click me}

<a href="">Click me</a>

缩写:p>{Click }+a{here}+{ to continue}

<p>Click <a href="">here</a> to continue</p>

隐式标签

缩写:.class

<div class="class"></div>

缩写:em>.class

<em><span class="class"></span></em>

缩写:ul>.class

<ul>
    <li class="class"></li>
</ul>

缩写:table>.row>.col

<table>
    <tr class="row">
        <td class="col"></td>
    </tr>
</table>

HTML

所有未知的缩写都会转换成标签,例如,foo → <foo></foo>

缩写:!

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>

</body>
</html>

缩写:a

<a href=""></a>

缩写:a:link

<a href="http://"></a>

缩写:a:mail

<a href="mailto:"></a>

缩写:abbr

<abbr title=""></abbr>

缩写:acronym

<acronym title=""></acronym>

缩写:base

<base href="" />

缩写:basefont

<basefont />

缩写:br

<br />

缩写:frame

<frame />

缩写:hr

<hr />

缩写:bdo

<bdo dir=""></bdo>

缩写:bdo:r

<bdo dir="rtl"></bdo>

缩写:bdo:l

<bdo dir="ltr"></bdo>

缩写:col

<col />

缩写:link

<link rel="stylesheet" href="" />

缩写:link:css

<link rel="stylesheet" href="style.css" />

缩写:link:print

<link rel="stylesheet" href="print.css" media="print" />

缩写:link:favicon

<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />

缩写:link:touch

<link rel="apple-touch-icon" href="favicon.png" />

缩写:link:rss

<link rel="alternate" type="application/rss+xml" title="RSS" href="rss.xml" />

缩写:link:atom

<link rel="alternate" type="application/atom+xml" title="Atom" href="atom.xml" />

缩写:meta

<meta />

缩写:meta:utf

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />

缩写:meta:win

<meta http-equiv="Content-Type" content="text/html;charset=windows-1251" />

缩写:meta:vp

<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />

缩写:meta:compat

<meta http-equiv="X-UA-Compatible" content="IE=7" />

缩写:style

<style></style>

缩写:script

<script></script>

缩写:script:src

<script src=""></script>

缩写:img

<img src="" alt="" />

缩写:iframe

<iframe src="" frameborder="0"></iframe>

缩写:embed

<embed src="" type="" />

缩写:object

<object data="" type=""></object>

缩写:param

<param name="" value="" />

缩写:map

<map name=""></map>

缩写:area

<area shape="" coords="" href="" alt="" />

缩写:area:d

<area shape="default" href="" alt="" />

缩写:area:c

<area shape="circle" coords="" href="" alt="" />

缩写:area:r

<area shape="rect" coords="" href="" alt="" />

缩写:area:p

<area shape="poly" coords="" href="" alt="" />

缩写:form

<form action=""></form>

缩写:form:get

<form action="" method="get"></form>

缩写:form:post

<form action="" method="post"></form>

缩写:label

<label for=""></label>

缩写:input

<input type="text" />

缩写:inp

<input type="text" name="" id="" />

缩写:input:hidden

别名:input[type=hidden name]

<input type="hidden" name="" />

缩写:input:h

别名:input:hidden

<input type="hidden" name="" />

缩写:input:text, input:t

别名:inp

<input type="text" name="" id="" />

缩写:input:search

别名:inp[type=search]

<input type="search" name="" id="" />

缩写:input:email

别名:inp[type=email]

<input type="email" name="" id="" />

缩写:input:url

别名:inp[type=url]

<input type="url" name="" id="" />

缩写:input:password

别名:inp[type=password]

<input type="password" name="" id="" />

缩写:input:p

别名:input:password

<input type="password" name="" id="" />

缩写:input:datetime

别名:inp[type=datetime]

<input type="datetime" name="" id="" />

缩写:input:date

别名:inp[type=date]

<input type="date" name="" id="" />

缩写:input:datetime-local

别名:inp[type=datetime-local]

<input type="datetime-local" name="" id="" />

缩写:input:month

别名:inp[type=month]

<input type="month" name="" id="" />

缩写:input:week

别名:inp[type=week]

<input type="week" name="" id="" />

缩写:input:time

别名:inp[type=time]

<input type="time" name="" id="" />

缩写:input:number

别名:inp[type=number]

<input type="number" name="" id="" />

缩写:input:color

别名:inp[type=color]

<input type="color" name="" id="" />

缩写:input:checkbox

别名:inp[type=checkbox]

<input type="checkbox" name="" id="" />

缩写:input:c

别名:input:checkbox

<input type="checkbox" name="" id="" />

缩写:input:radio

别名:inp[type=radio]

<input type="radio" name="" id="" />

缩写:input:r

别名:input:radio

<input type="radio" name="" id="" />

缩写:input:range

别名:inp[type=range]

<input type="range" name="" id="" />

缩写:input:file

别名:inp[type=file]

<input type="file" name="" id="" />

缩写:input:f

别名:input:file

<input type="file" name="" id="" />

缩写:input:submit

<input type="submit" value="" />

缩写:input:s

别名:input:submit

<input type="submit" value="" />

缩写:input:image

<input type="image" src="" alt="" />

缩写:input:i

别名:input:image

<input type="image" src="" alt="" />

缩写:input:button

<input type="button" value="" />

缩写:input:b

别名:input:button

<input type="button" value="" />

缩写:isindex

<isindex />

缩写:input:reset

别名:input:button[type=reset]

<input type="reset" value="" />

缩写:select

<select name="" id=""></select>

缩写:option

<option value=""></option>

缩写:textarea

<textarea name="" id="" cols="30" rows="10"></textarea>

缩写:menu:context

别名:menu[type=context]>

<menu type="context"></menu>

缩写:menu:c

别名:menu:context

<menu type="context"></menu>

缩写:menu:toolbar

别名:menu[type=toolbar]>

<menu type="toolbar"></menu>

缩写:menu:t

别名:menu:toolbar

<menu type="toolbar"></menu>

缩写:video

<video src=""></video>

缩写:audio

<audio src=""></audio>

缩写:html:xml

<html xmlns="http://www.w3.org/1999/xhtml"></html>

缩写:keygen

<keygen />

缩写:command

<command />

缩写:bq

别名:blockquote

<blockquote></blockquote>

缩写:acr

别名:acronym

<acronym title=""></acronym>

缩写:fig

别名:figure

<figure></figure>

缩写:figc

别名:figcaption

<figcaption></figcaption>

缩写:ifr

别名:iframe

<iframe src="" frameborder="0"></iframe>

缩写:emb

别名:embed

<embed src="" type="" />

缩写:obj

别名:object

<object data="" type=""></object>

缩写:src

别名:source

<source></source>

缩写:cap

别名:caption

<caption></caption>

缩写:colg

别名:colgroup

<colgroup></colgroup>

缩写:fst, fset

别名:fieldset

<fieldset></fieldset>

缩写:btn

别名:button

<button></button>

缩写:btn:b

别名:button[type=button]

<button type="button"></button>

缩写:btn:r

别名:button[type=reset]

<button type="reset"></button>

缩写:btn:s

别名:button[type=submit]

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

转自:http://www.w3cplus.com/tools/emmet-cheat-sheet.html

时间: 2024-10-11 08:41:55

emmet语法的相关文章

Emmet 语法

Emmet 是高效.快速编写 HTML 和 CSS 代码的一种插件,如果还不了解,请戳[Emmet — the essential toolkit for web-developers](http://docs.emmet.io/),再根据你使用的编辑器(sublime 或 vim 等)下载对应的 Emmet 插件,让你的代码快步如飞吧.下面我记录下常用的 Emmet 语法和快捷键.代码区里的均指在编辑器里输入的字符,然后按 “Tab” 键便会生成代码. 例如 输入`!` 然后按 “tab” 会

emmet语法列表

emmet语法 Child: > nav>ul>li <nav> <ul> <li></li> </ul> </nav> Sibling: + div+p+bq <div></div> <p></p> <blockquote></blockquote> Climb-up: ^ div+div>p>span+em^bq <div&

Emmet语法规则

Emmet插件仿照CSS语法来生成代码,使用emmet语法可以大大提高HTML/CSS代码书写的速度. 下面就来介绍一下Emmet语法到底应该如何书写; 当熟悉了Emmet的缩写语法之后,可能会想一些格式来生成更清晰可读的缩写,例如,在元素和运算符之间使用空格隔开 (header > ul.nav > li*5) + footer 注意:这种写法是错误的,空格是Emmet停止缩写解析的标志符.很多人会误认为每个缩写都应该写在新的一行上,实际上,可以在文本的任意位置输入和扩展缩写. 还有光标定在

Emmet 语法介绍

一.生成 HTML 文档初始结构 HTML 文档的初始结构,就是包括 doctype.html.head.body 以及 meta 等内容.你只需要输入一个 “!” 就可以生成一个 HTML5 的标准文档初始结构,你没有看错,输入一个感叹号(当然是英文符号),然后摁下 ctrl+E 键,就会发现生成了下面的结构: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&

Emmet 语法大全(缩写语法/sublime 插件)

Emmet 使用类似于 CSS 选择器的语法描述元素在生成的文档树中的位置及其属性. 元素 可以使用元素名(如 div 或者 p)来生成 HTML 标签.Emmet 没有预定义的有效元素名的集合,可以把任何单词当作标签来生成和使用:div → <div></div>, foo → <foo></foo> 等. 嵌套运算符 嵌套运算符用于以缩写的方式安排元素在生成文档树中的位置:将其放在内部或成为相邻的元素. 子: > 可以使用 > 运算符指定嵌套

Emmet语法实例(帮助快速开发)

写完命令后按键 tab 就可以生成了. 应用于大多数已经内置或可以安装emmet的编辑器下级元素命令 > <!--div>p--> <div> <p></p> </div> 同级元素命 + <!--div+p--> <div></div> <p></p> 上级元素命令 ^ <!--div>p>span^a--> <div> <p>

使用VsCode自带的Emmet语法

新建html文件,保存之后,输入"!",按Tap(或Enter)键,自动生成HTML结构 标签只要直接输入标签名(不要输入<>),按Tap(或Enter)键自动生成完整的标签 输入标签和id:标签名#id名 输入"span#sp",Tap(或Enter)键, => <span id="sp"></span> 输入标签和class值:标签名.class 名 输入"span.Sp",Tap

0012 sublime快捷操作emmet语法

Emmet的前身是Zen coding,它使用缩写,来提高html/css的编写速度. 生成标签 直接输入标签名 按tab键即可 比如 div 然后tab 键, 就可以生成 如果想要生成多个相同标签 加上 * 就可以了 比如 div*3 就可以快速生成3个div 如果有父子级关系的标签,可以用 > 比如 ul > li就可以了 如果有兄弟关系的标签,用 + 就可以了 比如 div+p 如果生成带有类名或者id名字的, 直接写 .demo 或者 #two tab 键就可以了.demo:p.hah

VScode中进行django开发,解决按tab实现emmet语法。

环境: vscode 1.43.1 Ubuntu 18.04.1 LTS x86_64 Python 3.6.8 pip3: Package          Version------------------- -------astroid 2.3.3 autopep8 1.5 Django 2.0 isort 4.3.21 lazy-object-proxy 1.4.3 mccabe 0.6.1 pip 20.0.2 pycodestyle 2.5.0 pylint 2.4.4 pylint