htmlvisual-studio-codetagsprettier

How to stop Prettier from using the old self closing tag syntax


So I recently installed prettier and whenever I save my file it adds the forwards slash in a self-closing tag. I was wondering how to stop it from doing this?

Here is what I mean:-

<!-- Instead of this ↓ -->
<input type="text">

<!-- It does this ↓ -->
<input type="text" />

Solution

  • It can't be changed because of a Prettier philosophy, see: https://github.com/prettier/prettier/issues/5641

    but you can change formatting of HTML files from Prettier to VS Code's formatter by adding in settings:

    "[html]": {
      "editor.defaultFormatter": "vscode.html-language-features"
    },
    

    like in this answer: https://stackoverflow.com/a/66646608/3248254