You can also look up documentation for Style Sheets, create and move rulesets, extract variables, and more.
IntelliJ IDEA provides code completion for properties, their values, selectors, variables, and mixins.
Complete Style Sheet classes
Completion for CSS, SCSS, Less, and Sass classes and ids is available in HTML files, in various types of templates (for example, in Angular or Vue.js), as well as in JSX code.
In HTML files, IntelliJ IDEA first suggests classes and ids from the
style tag and files linked with
link tags. If no matching results are found, IntelliJ IDEA also suggests symbols defined in all stylesheet files in the project. To see all classes and ids defined in the project straight away, before you start typing, press Ctrl+Space twice.
Search and navigation
To find usages of a Style Sheet symbol, place the caret at it and press Alt+F7. Learn more from Search for usages in a project.
To jump from a usage of a Style Sheet symbol to its definition, press Ctrl+B. Navigation to definition is available for classes, ids, selectors - including nested selectors and selectors with an ampersand (
&) - as well as for variables and mixins.
Learn more from Go to declaration.
For properties and pseudo-elements, IntelliJ IDEA can show you a summary from the corresponding MDN article. This summary is displayed in the Documentation popup which shows a brief description of the property and its values, as well as information about its compatibility with various browsers.
To view documentation for a property at caret
Press Ctrl+Q or select Documentation popup with a brief description of the property.from the main menu. IntelliJ IDEA opens a
If the property is available in all versions of browsers, IntelliJ IDEA does not show any information about its compatibility.
Otherwise, the Documentation popup also lists the browsers and their versions that support the property.
To open the MDN documentation in the browser
In the Documentation popup (Ctrl+Q), click the link at the bottom.
Press Shift+F1 or selectfrom the main menu.
With IntelliJ IDEA built-in formatter, you can reformat fragments of Style Sheet code as well as entire files and folders to meet the language-specific code style requirements. The formatter also wakes up automatically when you generate or refactor your code.
To configure formatting for a Style Sheet language, in the Settings/Preferences dialog (Ctrl+Alt+S), go to and configure the language-specific settings for tabs and indents, spaces, wrapping and braces, hard and soft margins, and so on.
To reformat a code fragment, select it in the editor and pressCtrl+Alt+L.
To reformat a file or a folder, select it in the Project tool window and press Ctrl+Alt+L.
See Reformat and rearrange code for more details.
With IntelliJ IDEA, you can convert expressions in Style Sheets into variables and introduce these variables using the
var(--var-name) syntax in .css files or the
$ syntax in .scss and .sass files.
To extract a variable
In the editor, position the caret at the expression to convert into a variable and press Ctrl+Alt+V or selectfrom the context menu or from the main menu.
If more than one occurrence of the selected expression is found, select Replace this occurrence only or Replace all occurrences from the Multiple occurrences found list.
For .scss, and .sass, select the global or local scope for the variable.
In the field with red borders, accept the suggested variable name or specify a custom name. Press Enter when ready.
With IntelliJ IDEA, you can create new rulesets from existing declarations in CSS, SCSS, Sass, or Less files and even move entire rulesets between files using refactoring and intention actions.
To extract a ruleset
Select the declarations to extract. If you need only one declaration, just position the caret inside it.
Press Alt+Enter and select Extract ruleset from the list.
IntelliJ IDEA creates a new ruleset with the same selector and moves the selected declarations to it. If the selection contains comments, nested selectors, and so on, they are also moved to the new ruleset.
To move a ruleset to another file
Position the caret anywhere in the ruleset and pressF6.
In the dialog that opens, specify the file to move the ruleset to. If the specified file does not exist, IntelliJ IDEA will suggest creating it.
By default, IntelliJ IDEA automatically opens the file where the ruleset is moved. To change this behavior, clear the Open in editor checkbox.
Common refactorings, such as Copy, Move, or Rename, are also available.
Checking compatibility with browsers
Besides looking up in the documentation popup, you can check Style Sheet properties for compatibility with specific browsers on the fly. This inspection is based on the MDN Browser Compatibility Data and shows you a warning every time a property is not supported in one of the targeted browsers.
In the Settings/Preferences dialog (Ctrl+Alt+S), go to .
Expand the CSS node and select the Browser compatibility for properties. In the Options area, select the browsers you want to target and the minimum versions for them.
Changing color values
With IntelliJ IDEA, you can easily change color values in Style Sheets without typing hexadecimal codes.
To choose a color
Open the desired Style Sheet for editing.
color:, and then press Ctrl+Space.
Select the desired color value from the suggestion list or choose color... to pick a custom one.
To change a color
Open the desired Style Sheet for editing, and locate the color property that you want to change.
Click the color icon in the gutter.
Alternatively, if the icons are not shown, press Alt+Enter and select Change color from the list.
In the Choose color dialog that opens, pick the desired new color and click Choose.
To preview the code of a color
IntelliJ IDEA marks each
colorproperty with a gutter icon of the corresponding color. When you hover over a color icon, IntelliJ IDEA displays a popup that shows the color preview and its hexadecimal code.
To show color icons in the gutter
By default, IntelliJ IDEA displays color icons in the gutter. If they are for some reason hidden, you can return them at any time.
In the Settings/Preferences dialog (Ctrl+Alt+S), go to . The Gutter Icons page opens.
In the Common area, select the Color preview checkbox.
Viewing the styles applied to a tag
In HTML, XHTML, JSP and JSPX files, IntelliJ IDEA can show you all the styles applied to an arbitrary tag.
From the context menu of a tag, select.
IntelliJ IDEA opens the CSS Styles tool window with two panes, the left-hand pane shows the styles for the tag and the right-hand pane shows their definitions. For each tag, IntelliJ IDEA opens a separate tab.
From the tool window, you can navigate to tags and definitions of properties in your source code.
To jump to the tag, click on the toolbar of the left-hand pane.
To jump to the definition of a property, select it in the left-hand pane and click on the toolbar of the right-hand pane.
Configuring syntax highlighting
You can configure CSS-aware syntax highlighting according to your preferences and habits.
In the Settings/Preferences dialog (Ctrl+Alt+S), go to .
Select the color scheme, accept the highlighting settings inherited from defaults or customize them as described in Configuring Colors and Fonts.