I used to spend forever typing out every single bracket and closing tag for my HTML. My fingers were getting so tired! But then we found out about Emmet. It’s like having a fast-forward button for our code editor…
Here is how we can stop typing and start shortcutting.
1. What is Emmet?
In simple terms, Emmet is a plugin as it's already inside VS Code that lets us write tiny shorthand codes that explode into full HTML. Instead of typing the whole thing, we just type a few letters, hit Tab, and boom the code appears…
2. Why it’s a Benefit For Beginners
When we are beginners, we make a lot of mistakes with brackets. Emmet writes the code perfectly for us, so we don't have to worry about forgetting a > or a closing </div>. It makes writing HTML feel like we are using a "cheat code."
3. The Boilerplate
Every HTML file needs that big block of boring setup code at the top. We don't have to copy-paste it anymore!
* The Secret: Just type ! and press Tab.
* The Result: It creates the whole <!DOCTYPE html>, <html>, <head>, and <body> tags in one second.
4. Writing Elements and Classes
This is where we save the most time. Check out these shortcuts:
* Element: Type h1 → Tab → <h1></h1>
* With a Class: Type p.my-text → Tab → <p class="my-text"></p>
* With an ID: Type div#header → Tab → <div id="header"></div>
5. Nesting and Repeating
This is my favorite part. If we want to make a list, we don't have to type <li> five times.
* Nesting (>): To put a span inside a p, we type p>span.
* Multiplication (*): If we want a list with 5 items, we just type ul>li*5. It creates the parent and all five children instantly!
6. Common Patterns We Use Daily
* div.container>div.box*3 – This creates a container with three boxes inside.
* a{Click Me} – This even puts the text "Click Me" inside the link for us!
Conclusion:
At first, it feels like learning a new language, but after one day, we will never want to go back to typing manual tags again. It’s optional, but it makes us feel like real pro developers.
Comments
Join the discussionNo comments yet. Be the first to comment.