As a web developer, we always try to increase the productivity and keep searching tool that helps us in it.
If you are one of them who write a lot of HTML and CSS then this post is for you.
Basically, most text editors out there allow you to store and re-use commonly used code chunks, called snippets. While snippets are a good way to boost your productivity. All implementations have common pitfalls: you have to define the snippet first and you can’t extend them in runtime.
All implementations have common pitfalls: you have to define the snippet first and you can’t extend them in runtime.
Emmet takes the snippets idea to a whole new level: you can type CSS-like expressions that can be dynamically parsed, and produce output depending on what you type in the abbreviation.
Emmet is developed and optimized for web-developers whose workflow depends on HTML/XML and CSS but can be used with programming languages too.
In this article, we will learn some cool tips to write HTML with amazing speed using Emmet.
Here in this tutorial, I am using Sublime as a Text Editor, But Emmet is also available for many other editions like Adobe DreamWeaver, TextMate, Eclipse, and Notepad++.
You can download Emmet from here. If you are using Sublime text like me you can install is directly from Sublime package Installer.
To install any Sublime package you need to install Package Installer. For installing go to Tools ->Install Package Control and click on it and it will be installed automatically. When you are done with installing package control again go to Tools-> command palette and search for Install Package.
When you click on Install Package you will see some processing at bottom of your Sublime window and a search popup will be opened.
You can search for any Sublime plugin here. Search for “Emmet” and click on it to install it.
NOTE- In below examples Tab key is used to expand the tags. Most of the text editors have the same built-in functionality.
What you do if you start creating any HTML project. You write HTML document code itself or copy it from anywhere. But Emmet provides the facility for generating basic HTML document structure easily.
You can generate by simply typing !(exclamation)+Tab or doc+Tab or HTML:4t+Tab and HTML doc will be in front of you
To write simple HTML, for example, for a div tag we just type div and hit Tab key. It can be used to create any tag.
We can assign any attribute like class, id, src etc. using Emmet-
If we want to assign just Id or class we can use # or . as we use in CSS.
As you see that if you just type #firstdiv by default div element will be created. If you want to specify an element you can type section#firstelement
But if you want to assign any other attribute you can specify easily in [] brackets. Suppose we want to assign src attribute to an img tag we can write
Sibling refers to the element at the same nesting level. If you want to create siblings or parallel element you can simply add + between elements.
Emmet uses the syntax similar to CSS, as we can select child element in CSS with the > sign. In Emmet, we use the same syntax to create child element.
If you want multiple elements inside an element you can achieve it by grouping them with ().
If you want to repeat the same element a number of times this will help you. We can generate multiple elements with an asterisk * sign.
Suppose we want to create 6 div with class=”main” we just simply type- .main*6
Automatic numbering will help you to easily write different name with auto incremental number. The right syntax for this feature is a dollar $ sign.
Also Read:
If you use dummy text by copying from lorem or lipsum or from somewhere else you don’t need to do that if you have Emmet. Emmet can generate lorem ipsum dummy text for you. we simply write lorem. It will generate a 5 to 7 line of Ipsum text.
In Emmet, we can specify how many words to generate. Say, 7 then type lorem7
If you have a favicon, rss or external CSS file you want to add to your document, you can use link tricks for writing them faster.
Emmet is a really brilliant tool to gain productivity for a web developer. You may face some difficulty in starting but once you pick it up it can significantly boost your productivity. You will be able to write HTML and CSS faster than ever before.
I am the owner of acmeextension. I am a passionate writter and reader. I like writting technical stuff and simplifying complex stuff.
Know More
Comments
I have installed emmet but still it is not working
When i press exclamation ❗ it show a green important there didn’t complete the syntax
Have also tried other shortcuts they are also not working
Please help
I simply want to mention I am very new to blogging and certainly enjoyed you’re web site. Most likely I’m going to bookmark your blog . You really come with remarkable article content. Appreciate it for revealing your web-site.
What’s up colleagues, its enormous paragraph about educationand entirely defined, keep it up all the time.
I’ve learn several just right stuff here. Definitely value bookmarking
for revisiting. I wonder how so much attempt you put to make any such fantastic informative
site.
pretty valuable material, overall I believe this is worth a bookmark, thanks
Very good article post.Really thank you! Will read on…
It as hard to come by well-informed people on this subject, however, you sound like you know what you are talking about! Thanks
Thanks a lot for the article post.Really looking forward to read more.
Yeah, bookmaking this wasn’t a bad determination outstanding post!
I have been absent for some time, but now I remember why I used to love this web site. Thanks, I will try and check back more often. How frequently you update your website?
Hi Borvest,
Its great to listen you liked it.
I try to update and add new content as much as possible.