Show
LoginRegister IntelliJ IDEA brings powerful support for HTML that includes syntax and error highlighting, formatting according to the code style, structure validation, code completion, on-the-fly preview during a debugging session (Live Edit) or
in the dedicated preview tab in the code editor, and much more. This functionality relies on the
HTML Tools plugin . The plugin comes bundled with IntelliJ IDEA, but if you observe any malfunction, make sure that the plugin is enabled. Note that the plugin and the supported functionality are not available for IntelliJ IDEA Community and Educational, it only works in the Ultimate edition. Press
Ctrl+Alt+S to open the IDE settings and select . Open the Installed tab, find the HTML Tools plugin, and make sure that the checkbox next to the plugin name is selected. HTML
specification is configurable with the Default HTML language level preference on the Languages & Frameworks | Schemas and DTDs page of the IDE settings
Ctrl+Alt+S. By default, specification HTML 5.0 from W3C is assumed. From the main menu, select , and then select HTML File from the list. IntelliJ IDEA creates a stub file based on the HTML file template and opens it in the editor. Inside a Alternatively, in the Project tool window, select the JavaScript, CSS, or image file you want to reference and drag it into the HTML file. IntelliJ IDEA generates the Select the code fragment to wrap and press Ctrl+Alt+T or select from the main menu. From the list, select Wrap with Tag. IntelliJ IDEA encloses the selection in a pair of brackets ( Type the tag inside the opening brackets Learn more from Generate code. For most HTML tags and attributes IntelliJ IDEA can show you a summary from the corresponding MDN article. This summary is displayed in the Documentation popup which also shows the deprecation status of a tag or an
attribute and information on its compatibility with various browsers. If the tag or the attribute 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 tag or the attribute. If the tag or the attribute is deprecated, the popup also informs you about this status. Position the caret at the tag or the attribute and press
Ctrl+Q or select
from the main menu. When you hover the mouse pointer over a tag or an attribute, IntelliJ IDEA immediately displays the reference for it in the Documentation popup. You can turn off this behavior or configure the popup to appear faster or slower, see
Configuring the behavior of Documentation popup below. To turn off showing documentation automatically when you hover the mouse over code symbols, Click
in the popup and disable the Show on Mouse Move option. To have the Documentation popup shown faster or slower, open the
Settings/Preferences dialog (Ctrl+Alt+S), go to , then select the Show the documentation popup checkbox and specify the delay time. In the Documentation popup
Ctrl+Q, click the link at the bottom. Press
Shift+F1 or select from the main menu. You can open the output of your HTML code in the built-in IntelliJ IDEA preview or externally, in a browser of your choice. By default, after you open an HTML file in the browser or in the built-in
preview, IntelliJ IDEA automatically reloads the page every time this HTML file (or any linked JavaScript or Style Sheet file) is saved manually or automatically, see Save and revert changes. You can change the default behavior to reload the page as you type so the changes to the HTML or related file immediately appear in the browser or in the built-in
preview. See Configure automatic reload below. IntelliJ IDEA built-in preview makes your work faster as you no longer need to switch to the browser and refresh the pages. The preview is opened in a
separate editor tab and reloaded automatically as you type or when you save the changes, depending on the reload behavior. From the main menu, select , and then select
from the list. Alternatively, hover your mouse pointer over the code to show the browser icons popup, and click . Preview an HTML file in a browserTo make sure your HTML code is rendered properly in production environment, preview HTML files in specific browsers. If you are using the built-in IntelliJ IDEA web server, the page is reloaded automatically when you save the changes or as you type, depending on the reload behavior.
Configure the browser icons in the popupOpen the Settings/Preferences dialog (Ctrl+Alt+S) and go to .
Configure automatic reloadBy default, after you open an HTML file in the browser or in the built-in preview, IntelliJ IDEA automatically reloads the page every time this HTML file (or any linked JavaScript or Style Sheet file) is saved manually or automatically, see Save and revert changes. When you save a file that triggers page reload, IntelliJ IDEA shows a Got it tooltip. You can change the default behavior to reload the page as you type so the changes to the HTML or related file immediately appear in the browser or in the built-in preview.
View HTML source code of a web page in the editor
View embedded imagesIntelliJ IDEA offers several ways to view images embedded in an HTML file. You can use navigation to source, open an image in an external graphical editor, or preview images on-the-fly. View images in IntelliJ IDEA
View images in an external editor
Change the default external editor
You can extract a fragment of HTML code into a separate include file. Entire JavaScript code blocks inside a Configure syntax highlightingYou can configure HTML-aware syntax highlighting according to your preferences and habits.
IntelliJ IDEA is aware of all standard HTML tags, and reports all unknown tags in your markup. If you use a framework that relies on custom HTML tags, such tags will be also reported as unknown, which would be a false positive in that case.
Last modified: 24 August 2022 |