PyCharm 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 code editor, and much more. Show
Enable the HTML Tools pluginThis functionality relies on the HTML Tools plugin, which is bundled and enabled in PyCharm by default. If the relevant features are not available, make sure that you did not disable the plugin. The HTML Tools plugin is available only in PyCharm Professional.
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. Create an HTML file
Create references in an HTML fileInside 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. PyCharm generates the Wrap code fragments in tags
Learn more from Generate code. Documentation look-upFor most HTML tags and attributes PyCharm 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, PyCharm 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. Compatibility is checked only for Chrome, Chrome Android, Safari, Safari iOS, Firefox, Internet Explorer, and Edge. If the tag or the attribute is deprecated, the popup also informs you about this status. View documentation for a tag or an attribute
Configure the behavior of Documentation popup
Open the MDN documentation for tags and attributes in the browser
Preview output of HTML filesYou can open the output of your HTML code in the built-in PyCharm preview or externally, in a browser of your choice. The preview functionality relies on the PyCharm built-in web server. This server is always running and does not require any manual configuration. All the project files are served on the built-in server with the root URL http://localhost:<built-in server port>/<project root>, with respect to the project structure. By default the built-in server port is set to the default PyCharm port 63342 through which PyCharm accepts connections from services. To change this default value, open the Settings dialog (Ctrl+Alt+S), go to Build, Execution, Deployment | Debugger, and in the Built-in Server specify any other value starting from 1024. By default, after you open an HTML file in the browser or in the built-in preview, PyCharm 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 below. PyCharm built-in previewPyCharm 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 . Open the PyCharm built-in preview
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 PyCharm web server, the page is reloaded automatically when you save the changes or as you type, depending on the . Automatic reload doesn't work when the page is uploaded to a manually configured default web server, see Configuring synchronization with a web server and for details.
Configure the browser icons in the popupOpen the Settings dialog (Ctrl+Alt+S) and go to Tools | Web Browsers and Preview.
Configure automatic reloadBy default, after you open an HTML file in the browser or in the built-in preview, PyCharm 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, PyCharm 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.
The changes to the reload behavior only take effect after you close the currently opened built-in or browser preview. View HTML source code of a web page in the editor
View embedded imagesPyCharm offers several ways to view images embedded in an HTML file. You can use , , or . View images in PyCharm
View images in an external editor
Change the default external editor
Extract include filesYou 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.
Configure custom HTML tagsPyCharm 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. |