How to Use Emmet in VS Code for HTML and CSS
· Category: VS Code & Developer Tools
Short answer
Emmet is a built-in toolkit in VS Code that expands abbreviations into full HTML and CSS code. It helps you write markup faster with CSS-selector-like syntax.
Steps
- Open an HTML file and type an abbreviation like
ul>li*5. - Press
TaborEnterto expand it into a list with five items. - For CSS, type
m10and press Tab to expand tomargin: 10px;. - Use
!followed by Tab to generate a complete HTML5 boilerplate. - Customize Emmet preferences in
settings.jsonunderemmet.*.
Tips
- Emmet works in JSX, Vue, and other templating languages with proper configuration.
- You can add custom snippets via
snippets.json. - Use grouping
()and numbering$for complex structures.
Common issues
- Emmet may not expand if the file language mode is not set correctly.
- Conflicting extensions can override the Tab key behavior.