DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Coding
  3. Languages
  4. How to Use Emmet to Speed Up Development

How to Use Emmet to Speed Up Development

Writing HTML can be a bit tedious a times. The free toolkit, Emmet, aims to take the monotony out of your coding and let you get back to being creative.

Angelo Frisina user avatar by
Angelo Frisina
·
Feb. 12, 19 · Tutorial
Like (2)
Save
Tweet
Share
9.70K Views

Join the DZone community and get the full member experience.

Join For Free

Writing code, especially HTML and CSS, can be a very tedious process — writing closing element tags or duplicate HTML elements that serve as the page's structure are repetitive, monotonous tasks that take up a lot of time. Fortunately, there is a freely available plugin that can speed up this process immeasurably. Emmet is a web development toolkit for writing HTML and CSS that can drastically change your workflow for the better. It exists as a plugin, available for all of the most popular text editors (Atom, Brackets, Sublime Text, and even vim). While a small book would be required to explain the full breadth of Emmet's features, this post will aim to teach the very basics of this extremely useful plugin. After you get used to its syntax, you will wonder how you ever coded/lived without Emmet.

How Emmet Works

While many of the most popular text editors have some basic form of auto-completion pre-installed; Emmet takes this to a whole new level. After inputting a value within Emmet's syntax, hitting the launch key will transform this input into HTML and CSS far beyond what you initially typed (this launch key is the TAB key by default, but can be customized to your liking). For example, Emmet can perform all of the standard features of auto-completion, such as typing p, followed by the TAB key, will result in:

<p></p>

Classes and IDs

Writing classes and IDs is simplified. A class is denoted by prepending a . before the class name, and an ID by prepending a # before the ID. For example, typing p.myClass#one becomes:

<p class="myClass" id="one"></p>

By default, any class or ID input that is not attached to a specified element will be assumed to be a div. For example, .containerbecomes

<div class="container"></div>

You can chain classes together, almost akin to chaining methods together in jQuery. Typing .class-one.class-two.class-three becomes:

<div class="class-one class-two class three">
</div>

You can nest multiple elements together. Typing div>ul>li>a will produce children elements:

<div>
    <ul>
        <li>
            <a href="" >
        </li>
    </ul>
</div>

Or you can create multiple adjacent siblings. For example,div+p+img becomes:

<div></div>
<p></p>
<img src=""></img>

Multiplication

One of the most useful features of Emmet (and the one that arguably cuts down on repetitive typing the most) is multiplication. You can multiply elements by a certain number, only having to type a single element once. Typing ul>li*7 will become:

<ul>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
</ul>

Conclusion

The full span of what Emmet is capable of is long. Luckily, there is fairly good documentation on the official site — this cheat sheet is particularly handy for the most common use-cases. While attempting to learn all of these shortcuts at the same time would be a tall order, incorporating even a small portion of these into your workflow can be a game-changer for your development efficiency.

Element Typing HTML Web development CSS workflow Syntax (programming languages) Bracket (tournament) Efficiency (statistics)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Continuous Development: Building the Thing Right, to Build the Right Thing
  • The 31 Flavors of Data Lineage and Why Vanilla Doesn’t Cut It
  • Top 5 Node.js REST API Frameworks
  • How to Quickly Build an Audio Editor With UI

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: