emmet 基本语法汇总

haibao 笔记 2014-09-01 22:09 422
授人以鱼不如授人以渔!授人以鱼只救一时之急, 授人以渔则可解一生之需。

欢迎您,我猜是来自美国的朋友! 本文共3165个字,预计阅读时间需要8分钟。

Emmet是一个可以提高前端开发效率的实用插件,你可以通过极短的代码输入来获得你想要的代码结构,而你需要做的前期工作就是花些时间来熟悉emmet本身的语法,其实这些语法看起来并不复杂,下面就向大家分享一下emmet常用的基本语法。

一旦上手熟练emmet的基本语法之后,你会发现写代码是一件无比轻松愉快的事情!

html结构快速输出

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
Child: > 
 
输入:nav>ul>li
输出:
<nav>
    <ul>
      <li></li>
    </ul>
</nav>
 
Multiplication: *  
 
输入:ul>li*5
输出:
<ul>
   <li></li>
   <li></li>
   <li></li>
   <li></li>
   <li></li>
</ul>
 
Item numbering: $
 
输入: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>li.item$@-*5
输出:
<ul>
   <li class="item5"></li>
   <li class="item4"></li>
   <li class="item3"></li>
   <li class="item2"></li>
   <li class="item1"></li>
</ul>
 
输入:ul>li.item$@3*5
输出:
<ul>
   <li class="item3"></li>
   <li class="item4"></li>
   <li class="item5"></li>
   <li class="item6"></li>
   <li class="item7"></li>
</ul>
 
输入:form#search.wide
输出: <form id="search" class="wide"></form>
 
输入:p.class1.class2.class3
输出:<p class="class1 class2 class3"></p>
 
ID and CLASS attributes 快速输出id和class标签结构
 
输入:#header
输出:
<div id="header"></div>
输入:.header
输出:
<div class="header"></div>
 
Sibling: + 组合标签
 
输入:div+p+bq
输出:
<div></div>
<p></p>
<blockquote></blockquote>
 
Climb-up: ^
 
输入: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>
 
Grouping: ()
 
输入: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>
 
Custom attributes 自定义对象
 
输入: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>
 
Text: {}
 
输入:a{Click me}
输出:<a href="">Click me</a>
 
输入:p>{Click }+a{here}+{ to continue}
输出:<p>Click <a href="">here</a> to continue</p>
 
Implicit tag names
 
输入:.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元素快速输出

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
输入:html:5
输出:
<!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
 
    Alias of input[type=hidden name]
    <input type="hidden" name="" />
 
input:h
 
    Alias of input:hidden
    <input type="hidden" name="" />
 
input:text, input:t
 
    Alias of inp
    <input type="text" name="" id="" />
 
input:search
 
    Alias of inp[type=search]
    <input type="search" name="" id="" />
 
input:email
 
    Alias of inp[type=email]
    <input type="email" name="" id="" />
 
input:url
 
    Alias of inp[type=url]
    <input type="url" name="" id="" />
 
input:password
 
    Alias of inp[type=password]
    <input type="password" name="" id="" />
 
input:p
 
    Alias of input:password
    <input type="password" name="" id="" />
 
input:datetime
 
    Alias of inp[type=datetime]
    <input type="datetime" name="" id="" />
 
input:date
 
    Alias of inp[type=date]
    <input type="date" name="" id="" />
 
input:datetime-local
 
    Alias of inp[type=datetime-local]
    <input type="datetime-local" name="" id="" />
 
input:month
 
    Alias of inp[type=month]
    <input type="month" name="" id="" />
 
input:week
 
    Alias of inp[type=week]
    <input type="week" name="" id="" />
 
input:time
 
    Alias of inp[type=time]
    <input type="time" name="" id="" />
 
input:number
 
    Alias of inp[type=number]
    <input type="number" name="" id="" />
 
input:color
 
    Alias of inp[type=color]
    <input type="color" name="" id="" />
 
input:checkbox
 
    <input type="checkbox" name="" id="" />
 
input:c
 
    Alias of input:checkbox
    <input type="checkbox" name="" id="" />
 
input:radio
 
    Alias of inp[type=radio]
    <input type="radio" name="" id="" />
 
input:r
 
    Alias of input:radio
    <input type="radio" name="" id="" />
 
input:range
 
    Alias of inp[type=range]
    <input type="range" name="" id="" />
 
input:file
 
    Alias of inp[type=file]
    <input type="file" name="" id="" />
 
input:f
 
    Alias of input:file
    <input type="file" name="" id="" />
 
input:submit
    <input type="submit" value="" />
 
input:s
 
    Alias of input:submit
    <input type="submit" value="" />
 
input:image
    <input type="image" src="" alt="" />
 
input:i
 
    Alias of input:image
    <input type="image" src="" alt="" />
 
input:button
    <input type="button" value="" />
 
input:b
 
    Alias of input:button
    <input type="button" value="" />
 
isindex
    <isindex />
 
input:reset
 
    Alias of 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
 
    Alias of menu[type=context]>
    <menu type="context"></menu>
 
menu:c
 
    Alias of menu:context
    <menu type="context"></menu>
 
menu:toolbar
 
    Alias of menu[type=toolbar]>
    <menu type="toolbar"></menu>
 
menu:t
 
    Alias of 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
 
    Alias of blockquote
    <blockquote></blockquote>
 
acr
 
    Alias of acronym
    <acronym title=""></acronym>
 
fig
 
    Alias of figure
    <figure></figure>
 
figc
 
    Alias of figcaption
    <figcaption></figcaption>
 
ifr
 
    Alias of iframe
    <iframe src="" frameborder="0"></iframe>
 
emb
 
    Alias of embed
    <embed src="" type="" />
 
obj
 
    Alias of object
    <object data="" type=""></object>
 
src
 
    Alias of source
    <source></source>
 
cap
 
    Alias of caption
    <caption></caption>
 
colg
 
    Alias of colgroup
    <colgroup></colgroup>
 
fst, fset
 
    Alias of fieldset
    <fieldset></fieldset>
 
btn
 
    Alias of button
    <button></button>
 
btn:b
 
    Alias of button[type=button]
    <button type="button"></button>
 
btn:r
 
    Alias of button[type=reset]
    <button type="reset"></button>
 
btn:s
 
    Alias of button[type=submit]
    <button type="submit"></button>
 
optg
 
    Alias of optgroup
    <optgroup></optgroup>
 
opt
 
    Alias of option
    <option value=""></option>
 
tarea
 
    Alias of textarea
    <textarea name="" id="" cols="30" rows="10"></textarea>
 
leg
 
    Alias of legend
    <legend></legend>
 
sect
 
    Alias of section
    <section></section>
 
art
 
    Alias of article
    <article></article>
 
hdr
 
    Alias of header
    <header></header>
 
ftr
 
    Alias of footer
    <footer></footer>
 
adr
 
    Alias of address
    <address></address>
 
dlg
 
    Alias of dialog
    <dialog></dialog>
 
str
 
    Alias of strong
    <strong></strong>
 
prog
 
    Alias of progress
    <progress></progress>
 
datag
 
    Alias of datagrid
    <datagrid></datagrid>
 
datal
 
    Alias of datalist
    <datalist></datalist>
 
kg
 
    Alias of keygen
    <keygen />
 
out
 
    Alias of output
    <output></output>
 
det
 
    Alias of details
    <details></details>
 
cmd
 
    Alias of command
    <command />
 
ol+
 
    Alias of ol>li
    <ol> <li></li> </ol>
 
ul+
 
    Alias of ul>li
    <ul> <li></li> </ul>
 
dl+
 
    Alias of dl>dt+dd
    <dl> <dt></dt> <dd></dd> </dl>
 
map+
 
    Alias of map>area
    <map name=""> <area shape="" coords="" href="" alt="" /> </map>
 
table+
 
    Alias of table>tr>td
    <table> <tr> <td></td> </tr> </table>
 
colgroup+, colg+
 
    Alias of colgroup>col
    <colgroup> <col /> </colgroup>
 
tr+
 
    Alias of tr>td
    <tr> <td></td> </tr>
 
select+
 
    Alias of select>option
    <select name="" id=""> <option value=""></option> </select>
 
optgroup+, optg+
 
    Alias of optgroup>option
    <optgroup> <option value=""></option> </optgroup>
 
!!!
    <!doctype html>
 
!!!4t
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 
!!!4s
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
 
!!!xt
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
!!!xs
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 
!!!xxs
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
 
c
    <!-- ${child} -->
 
cc:ie6
    <!--[if lte IE 6]> ${child} <![endif]-->
 
cc:ie
    <!--[if IE]> ${child} <![endif]-->
 
cc:noie
    <!--[if !IE]><!--> ${child} <!--<![endif]-->

本文标题:emmet 基本语法汇总

本文地址:http://www.hehaibao.com/emmet/

版权声明:本博客所有文章除特别声明外,均采用 CC BY-NC-SA 3.0 许可协议。转载请注明出处!

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>