Shortcuts can make or break a developer’s productivity. It also turns out that Visual Studio Code comes with a pre-baked shorthand that lets you print out HTML code templates. This feature is mostly unknown to many beginner (and even veteran) users of VS Code. This is partly because we become complacent to just typing everything out manually.

If you’re a frontend developer, these shorthand syntaxes should save you a ton of time and make your code tighter from the get-go. All you have to do is boot up your VS Code editor and type out the shorthand you want.

ID and Class Attributes

You can create an id by using the # symbol with the attribute you want to create. For example:


Will generate:

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

If you want a class, use the . instead. For example:


Will generate:

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

What if you want both an id and a class together? You can mix and match using both the # and . symbols. For example:


This will generate:

<div id="nav" class="dark"></div>

If you want multiple classes, just chain them together like this:

This will generate:

<p class="highlight green"></p>


What if you want multiple elements printed? This is where the * sign comes in. The simplest way to remember it is that you are multiplying the element you want to print.

For example:


Will print:


If you want it to nest under another element, use the > symbol. The > will turn whatever follows into a child. For example:


This will print:


Making siblings

What if you want to make multiple elements at once? This is where siblings come in. All you have to do is use the + sign. For example:


This will create:


Adding text

Let’s say you want to add some text whilst using this shorthand in Visual Studio Code. All you have to do is use the curly braces {} to surround the text you want.

For example:


Will create:



What if you want to create a bunch of elements in one go and include everything mentioned above in some form? This is where () comes in.

Whatever () pair surrounds is counted as a group and gets nested accordingly. For example:


Will create the following:

            <li><a href="" class="blue"></a></li>      
            <li><a href="" class="blue"></a></li>      
            <li><a href="" class="blue"></a></li>      
    <div class="body"></div>
    <footer class="dark"></footer>

Implicit tag names

When it comes to construction HTML documents, there are certain patterns that are simply expected. For example, a ul will always have li as a child. You can shorthand implicit tags in Visual Studio like this:


This will print the following:

    <li class="someclass"></li>

Item numbering

When it comes to shorthand in VS Code, you can do simple numeric logic. For example, if you want a class to be named and incremented automatically, you can use the $* combination to achieve this. For example:


The above will print:

    <li class="list-item-1"></li>   
    <li class="list-item-2"></li>   
    <li class="list-item-3"></li>

Wrap up

That’s basically it. It doesn’t matter if you’re working with React, Angular, Vue, or any kind of frontend library or framework, you’re going to encounter HTML in some form or another.

Typing everything out by hand is a tedious process and can be prone to errors, especially when it comes to siblings and nesting. These shorthand tricks don’t require any additional installations or add-ons to work — they just do.

Share this post