Method 1: Use HTML script tag
- Create an HTML file in VS Code and inside the file, add the
- Save the changes and then open the HTML file in the browser.
- In the browser, open the inspect window by right-clicking the mouse and select Inspect option. You can also open it by clicking Ctrl + Shift + I keys for Windows, or Cmd + Option + I keys for Mac.
The only downside of using this approach is you will constantly switch between a browser and VS Code windows. Unless you’re working on smaller windows or have two monitor screens, this will inconvenience you a little bit.
Method 2: Use Node.js
- Download and install Node.js on your computer.
- Open VS Code’s terminal by clicking Terminal > New Terminal, or clicking Ctrl + Shift + ` keys (Cmd + Shift+ P for Mac).
- In the terminal, type
Method 3: Use Code Runner Extension
- Click the Extensions tab, and search for Code Runner and install it.