WebStorm 2016.2 Help

Code Style. HTML

File | Settings | Editor | Code Style | HTML for Windows and Linux

WebStorm | Preferences | Editor | Code Style | HTML for OS X


Use this page to configure formatting options for HTML files. View the result in the Preview pane on the right.

On this page:

Tabs and Indents

ItemDescription
Use tab character
  • If this check box is selected, tab characters are used:
    • On pressing the Tab key
    • For indentation
    • For code reformatting
  • When the check box is cleared, WebStorm uses spaces instead of tabs.
Smart tabs
  • If this check box is selected, WebStorm inserts tabs for indentation and reformatting. WebStorm inserts tabs in the beginning of each line until a symbol other than the tab is inserted. After that when you press the tab key, WebStorm will enter spaces.
  • If this check box is cleared, only tabs are used. This means that a group of spaces that fits the specified tab size is automatically replaced with a tab, which may result in breaking fine alignment.

The Smart Tabs check box is available if the Use Tab Character check box is selected.

Tab sizeIn this text box, specify the number of spaces included in a tab.
IndentIn this text box, specify the number of spaces (or tabs if the Use Tab Character check box is selected) to be inserted for each indent level.
Continuation indentIn this text box, specify the number of spaces (or tabs if the Use Tab Character check box is selected) to be inserted between the elements of an array, in expressions, method declarations and method calls.
Keep indents on empty linesIf this check box is cleared, then WebStorm will keep indents on the empty lines as if they contained some code.
If this check box is not selected, WebStorm will delete the tabulation characters.
Indent all chained calls in a group The check box is available only when the Indent chained methods check box is selected.

Other

ItemDescription
Right MarginUse these settings to specify a margin space required on the right side of an element. If you select Default option then a value of the right margin from the global settings will be used.
Wrap on typingUse these settings settings to specify how the edited text is fitted in the specified Right margin. You can select one the following options:
  • Default - in this case WebStorm uses the Wrap on typing option that is specified in the global settings.
  • Yes - in this case the value in the specified right margin is used.
  • No - in this case this option is switched off and a line can exceed the number that is specified in the right margin.
Keep line breaksSelect this check box to have WebStorm honor line breaks when reviewing HTML files in the editor.
Keep line breaks in textSelect this check box to have WebStorm honor line breaks in attributes (for example, lengthy descriptions) when reviewing HTML files in the editor.
Keep blank linesIn this text box, specify the minimum number of sequential blank lines to be retained after reformatting.
Wrap attributesUse this drop-down list to determine how attribute lines should be wrapped. The available options are:
  • Do not wrap - if this option is selected, no special wrapping style is applied to the code.
  • Wrap if long - select this option to have lines going beyond the right margin wrapped with proper indentation.
  • Chop down if long - select this option to have elements in lists that go beyond the right margin wrapped to give one element per line with proper indentation.
  • Wrap always - select this option to have all elements in lists wrapped to give one element per line with proper indentation.
Wrap textSelect this check box to have long lines wrapped according to the code style settings.
Align attributesSelect this check box to have attributes in sequential lines aligned.
Align textSelect this check box to have WebStorm align the text that occupies several lines within a tag.
Keep white spacesSelect this check box to suppress replacing actual white spaces with tabs.
SpacesIn this area, define the use of spaces for attributes and tag names.
  • Around "=" in attribute - select this check box to have spaces added around the "=" symbol in attributes.
  • After tag name - select this check box to have spaces added after tag names.
  • In empty tag - select this check box to have spaces added in empty tags.
Insert new line beforeThis display field shows a list of tags before which a new line should be inserted. Use the button shift-enter-button.png next to the field or press Shift+Enter to open the Insert New Line Before Tags dialog box, where you can edit the list of tags.
Remove new line beforeThis display field shows a list of tags before which a break line should be removed. Use the button shift-enter-button.png next to the field or press Shift+Enter to open the Remove Line Breaks Before Tags dialog box, where you can edit the list of tags.
Do not indent children ofThis display field shows a list of tags whose children should not be indented. Use the button shift-enter-button.png next to the field or press Shift+Enter to open the Do Not Indent Children Of dialog box, where you can edit the list of tags.
Or if tag size more thanIn this text box, specify the minimum length of a tag in lines starting from which its children are not indented.
Inline elementsThis display field shows a list of tags that are presented in the source code in the same line with the other tags. If a tag is removed from the list, the editor automatically moves it to a new line, when you add such tag to the source code. Use the button shift-enter-button.png next to the field or press Shift+Enter to open the Inline Elements dialog box, where you can edit the list of tags.
Keep white spaces insideThis display field shows a list of tags inside which you want the editor to preserve white spaces as is, without any changes. Use the button shift-enter-button.png next to the field or press Shift+Enter to open the Keep Whitespaces Inside dialog box, where you can edit the list of tags.
Don't break if inline contentThis display field shows a list of tags that are not to be wrapped if their content is inlined. Use the button shift-enter-button.png next to the field or press Shift+Enter to open the Don't Wrap If Inline Content Only dialog box, where you can edit the list of tags.
Generated quote marks Choose the style of the quote marks (double, single, or none) to be automatically inserted around HTML attributes on typing =.

This is important when HTML is inserted dynamically using JavaScript and you want to consistently use double-quote pairs for JavaScript strings and single-quote pairs for HTML to prevent problems, for example, when copying and pasting.

Enforce on formatIf this check box is selected, then on code reformatting the previously generated quote marks will be replaced (for example, double quotes with single quotes).

Set from...

Click this link to reveal the list of languages to be used as the base for the current language code style. So doing, only the settings that are applicable to the current language are taken. All the other settings are not affected.

This link appears in the upper-right corner of the language-specific code style page, when applicable.

Click Reset to discard changes and return to the initial set of code style settings.

See Also

Last modified: 15 November 2016