DEV Community

Cover image for Emmet Part 2 - Advanced
codeSTACKr
codeSTACKr

Posted on • Edited on • Originally published at codestackr.com

5

Emmet Part 2 - Advanced

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>
Enter fullscreen mode Exit fullscreen mode

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>
Enter fullscreen mode Exit fullscreen mode

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>
Enter fullscreen mode Exit fullscreen mode

Attributes

We can also easily add attributes to any tag using square brackets.

  • p[title="Hello World"]
<p title="Hello World"></p>
Enter fullscreen mode Exit fullscreen mode

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>
Enter fullscreen mode Exit fullscreen mode

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>
Enter fullscreen mode Exit fullscreen mode

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;
Enter fullscreen mode Exit fullscreen mode

Part 3 coming very soon! Check out the full video on my YouTube channel.

Thanks for reading!

Say Hello! Instagram | Twitter | YouTube

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay