CSS, SCSS and Less
Visual Studio Code has built-in support for editing style sheets in CSS .css
, SCSS .scss
and Less .less
. In addition, you can install an extension for greater functionality.
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.
IntelliSense
VS Code has support for selectors, properties and values. Use Ctrl+Space
to get a list of context specific options.
Proposals contain extensive documentation, including a list of browsers that support the property. To see the full description text of the selected entry, use kb(toggleSuggestionDetails)
.
Syntax coloring & color preview
As you type, there is syntax highlighting as well as in context preview of colors.
Clicking on a color preview will launch the integrated color picker which supports configuration of hue, saturation and opacity.
Tip: You can trigger between different color modes by clicking on the color string at the top of the picker.
You can hide VS Code's color previews by setting the following setting:
"editor.colorDecorators": false
To just disable it for css, Less and SCSS, use
"[css]": {
"editor.colorDecorators": false
}
Folding
You can fold regions of source code using the folding icons on the gutter between line numbers and line start. Folding regions are available for all declarations (for example, rule declarations) and for multiline comments in the source code.
Additionally you can use the following region markers to define a folding region:
/*#region*/
and /*#endregion*/
in CSS/SCSS/Less or // #region
and // #endregion
In SCSS/Less.
If you prefer to switch to indentation based folding for CSS, Less and SCSS, use:
"[css]": {
"editor.foldingStrategy": "indentation"
},
Emmet snippets
Emmet abbreviation support is built into VS Code, suggestions are listed along with other suggestions and snippets in the editor auto-completion list.
Tip: See the CSS section of the Emmet cheat sheet for valid abbreviations.
VS Code also supports User Defined Snippets.
Syntax Verification & Linting
There is support for CSS version <= 2.1, Sass version <= 3.2 and Less version <= 2.3.
Note: You can disable VS Code's default CSS, Sass or Less validation by setting the corresponding
.validate
User or Workspace setting to false."css.validate": false
Go to Symbol in file
You can quickly navigate to the relevant CSS symbol in the current file by pressing kb(workbench.action.gotoSymbol)
.
Hovers
Hovering over a selector or property will provide an HTML snippet that is matched by the CSS rule.
Go to Declaration and Find References
This is supported for Sass and Less variables in the same file. CSS variables per the draft standards proposal are also supported.
There is jump to definition for @import
and url()
links in CSS, SCSS and Less.
CSS custom data
You can extend VS Code's CSS support through a declarative custom data format. By setting css.customData
to a list of JSON files following the custom data format, you can enhance VS Code's understanding of new CSS properties, at-directives, pseudo-classes and pesudo-elements. VS Code will then offer language support such as completion & hover information for the provided properties, at-directives, pseudo-classes and pesudo-elements.
You can read more about using custom data in the vscode-custom-data repository.