How to run html in Visual Studio Code (Windows 10 and Mac OS)

In web development, as web development basically starts with writing HTML web pages. This article describes how to get started configuring your development environment to run HTML code.

HTML can be run in VS Code on both Windows and Mac.

  1. Open VS Code, install Code Runner in VS Code , as shown below

2. This is the way to run and stop running code in the Code Runner installation introduction

3、Windows 点击: File --> Preferences --> Settings

Mac Click : Code --> Preferences -->  Settings

4. Click the icon button on the right side of setting to open a json file

5. In the settings.json file, add a line code-runner.executorMap,

Enter the code here, you can directly select the following function without typing it by hand, and then press Enter

Remember to enter a comma "," at the end of the previous line

6. Add the function of running html in Code Runner! (Note the commas !)

Windows users : (differentiate between browsers, choose your corresponding browser)

Command [Chrome]: "html":"cd $dir && start chrome $dir && $fileName",

Command [Edge]: "html":"cd $dir && start msedge $dir && $fileName",

Command [Firefox]: "html":"cd $dir && start firefox $dir && $fileName",

If the above command line does not work, you can try the following corresponding command:

Command [Chrome]: "html":"cd $dir && start chrome $fileName",

Command [Edge] : "html":"cd $dir && start msedge $fileName",

Command [Firefox] : "html":"cd $dir && start firefox $fileName",

Mac users :

"html":"cd $dir && open -a 'Google Chrome' $fileName",

7. You can run an html test below, click to run, and it will automatically jump to the chrome browser (if you use chrome)

(ps. The body text has been modified here, but the essence is like this)

Guess you like

Origin blog.csdn.net/ok060/article/details/131023605