9

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" />

Thank you in advance

Leji Kedus -_-
  • 107
  • 1
  • 1
  • 7

2 Answers2

8

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

zdolny
  • 999
  • 1
  • 11
  • 21
0

Its working like this with liveserver. But when ı run npx prettier --write . . Closed all "input" and "img" tags.

{ 
  "[html]": {
    "editor.defaultFormatter": "vscode.html-language-features"
  },
  "liveServer.settings.port": 5539,
  "liveServer.settings.root": "/public/", 
}