Creating an HTML file
On the main menu, choose , and then choose HTML File in the pop-up list. IntelliJ IDEA creates a stub file and opens it in the editor.
The stub is generated using the HTML file template.
Editing an HTML file
IntelliJ IDEA can generate <script>, <link>, or <img> tags inside <head>.
To generate a tag, drag the
-
To generate a
scripttag
When a file is opened for editing, you can drag a JavaScript or CSS file into the opened HTML file.
IntelliJ IDEA will automatically create a script or a link tag inside the <head> tag.
Same way, you can drag an image to add an img tag with the width and
height attributes anywhere inside the <body> tag.

No preliminary steps are required to view HTML code. However, to preview PHP pages in the browser, you need to configure synchronization with a server first.
Previewing pages with web content in a browser
You can preview a file with Web contents in a browser. This can be the IntelliJ IDEA default browser specified in the Web Browsers section of the IDE settings or the one of your choice.
- On the main menu, choose . The current file opens in the default browser.
-
With the editor tab having the focus, choose on the main menu or press Alt+F2.
Then select the desired browser from the pop-up menu:

-
Hover your mouse pointer over the code to show the browser icons bar, and click the icon that indicates the desired browser:

If you don't want to see the icons toolbar, or would like to see the icons of just those browsers you are interested in, clear the Active check boxes for the unnecessary browsers in the Web Browsers section of the IDE settings.
- Choose .
- In the Open URL dialog box that opens, type the URL address of the web page or choose a previously opened URL from the list.
Viewing embedded images
IntelliJ IDEA suggests several ways to view images, embedded in the HTML files. You can use navigation to source, open an image in an external graphical editor, or preview images on-the-fly. The viewing modes are configurable in the Images dialog.
- In the Project tool window, select the desired image file.
- On the context menu of the file, choose , or press F4.
Configure the path to the desired external editor in the External Editor section of the Images dialog.
- In the Project tool window, select an image file.
- On the context menu of the file, choose , or press Ctrl+Alt+F4.
- On the context menu, choose .
- Invoke the Navigate to declaration feature by pressing Ctrl+B.