HTML Programming in VS Code
Visual Studio Code provides basic support for HTML programming out of the box. There is syntax highlighting, smart completions with IntelliSense, and customizable formatting. VS Code also includes great Emmet support.
As you type in HTML, we offer suggestions via HTML IntelliSense. In the image below you can see a suggested HTML element closure
</div> as well as a context specific list of suggested elements.
We also offer up suggestions for elements, tags, some values (as defined in HTML5), Ionic and AngularJS tags. Document symbols are also available for HTML, allowing you to quickly navigate to DOM nodes by id and class name.
You can trigger suggestions at any time by pressing ⌃Space (Windows, Linux Ctrl+Space).
You can also control which built-in code completion providers are active. Override these in your user or workspace settings if you prefer not to see the corresponding suggestions.
// Configures if the built-in HTML language suggests Angular V1 tags and properties. "html.suggest.angular1": true, // Configures if the built-in HTML language suggests Ionic tags, properties and values. "html.suggest.ionic": true, // Configures if the built-in HTML language suggests HTML5 tags, properties and values. "html.suggest.html5": true
Tag elements are automatically closed when
> of the opening tag is typed.
The matching closing tag is inserted when
/ of the closing tag is entered.
You can turn off autoclosing tags with the following setting:
The VS Code color picker UI is now available in HTML style sections.
You can turn that validation off with the following settings:
// Configures if the built-in HTML language support validates embedded scripts. "html.validate.scripts": true, // Configures if the built-in HTML language support validates embedded styles. "html.validate.styles": true
To improve the formatting of your HTML source code, press ⌘K ⌘F (Windows, Linux Ctrl+K Ctrl+F) and the selected area will be reformatted.
html.format.wrapLineLength: Maximum amount of characters per line.
html.format.unformatted: List of tags that shouldn't be reformatted.
html.format.extraLiners: List of tags that should have an extra newline before them.
html.format.preserveNewLines: Whether existing line breaks before elements should be preserved.
html.format.maxPreserveNewLines: Maximum number of line breaks to be preserved in one chunk.
html.format.endWithNewline: End with a newline.
html.format.wrapAttributes: Wrapping strategy for attributes:
auto: Wrap when the line length is exceeded
force: Wrap all attributes, except first
force-aligned: Wrap all attributes, except first, and align attributes
force-expand-multiline: Wrap all attributes
Tip: The formatter does not format the tags listed in the
We support Emmet snippet expansion. Emmet abbreviations are listed along with other suggestions and snippets in the editor auto-completion list.
Tip: See the HTML section of the Emmet cheat sheet for valid abbreviations.
If you'd like to use HTML Emmet abbreviations with other languages, you can associate one of the Emmet modes (such as
html) with other languages with the
emmet.includeLanguages setting. The setting takes a language id and associates it with the language id of an Emmet supported mode.
We also support User Defined Snippets.
Install an extension to add more functionality. Go to the Extensions view (⇧⌘X (Windows, Linux Ctrl+Shift+X)) and type 'html' to see a list of relevant extensions to help with creating and editing HTML.
Tip: Click on an extension tile above to read the description and reviews to decide which extension is best for you. See more in the Marketplace.
Read on to find out about:
- CSS, Less and Sass - VS Code has first class support for CSS including Less and Sass.
- Emmet - Learn about VS Code's powerful built-in Emmet support.
Q: Does VS Code have HTML preview?
A: No, VS Code doesn't have built-it support for HTML preview but there are extensions available in the VS Code Marketplace. Open the Extensions view (⇧⌘X (Windows, Linux Ctrl+Shift+X)) and search on 'live preview' or 'html preview' to see a list of available HTML preview extensions.