If you haven't read Emmet Part 1 - Basics, check that out first:
In this post, we cover the following topics:
📌 Boilerplates
📌 Climb Up
📌 Grouping
📌 Attributes
📌 Item Numbering
📌 Implicit Tags
📌 CSS Sneak Peek
Part 3 coming soon!
Boilerplate
You can create a basic HTML boilerplate easily! <--
- !
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Document</title>
</head>
<body>
</body>
</html>
Climb Up
With Emmet we can easily traverse multiple levels. Here we can climb up a level using ^
- div+div>p>span+em^bq
<div></div>
<div>
<p><span></span><em></em></p>
<blockquote></blockquote>
</div>
Grouping
We can achieve something similar by using grouping. To group, surround parts of the code with parenthesis.
- div>(hdr>ul>li*2>a)+ftr>p
<div>
<header>
<ul>
<li><a href=""></a></li>
<li><a href=""></a></li>
</ul>
</header>
<footer>
<p></p>
</footer>
</div>
Attributes
We can also easily add attributes to any tag using square brackets.
- p[title="Hello World"]
<p title="Hello World"></p>
Item Numbering
When multiplying items, an index is tracked. We can use the index by inserting the $ sign.
- h$[title=item$]{Header $}*3
<h1 title="item1">Header 1</h1>
<h2 title="item2">Header 2</h1>
<h3 title="item3">Header 3</h1>
Implicit Tags
tags do not always need to be used. In some cases they are implied. Here we create a table with a row and a column without specifying the tr
or td
.
- table>.row>.col
<table>
<tr class="row">
<td class="col"></td>
</tr>
</table>
CSS Sneak Peek
Emmet can be used for CSS too! Part 3 will be all about fast CSS workflows.
- pos
- pos:s
- pos:a
- pos:r
- pos:f
position:relative;
position:static;
position:absolute;
position:relative;
position:fixed;
Part 3 coming very soon! Check out the full video on my YouTube channel.
Top comments (0)