How to Stop Prettier From Using Forwards Slash in a Self-Closing Tag

stop-prettier-self-closing-tag-feature-image

A Developer asked on Stackoverflow platform : –

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

The solution to this problem is simple:

First of all, we can’t change it directly because of Prettier philosophy, rather can change formatting of HTML files from Prettier to VS Code’s formatter by adding in settings:

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

Resources

How useful was this post?

Click on a star to rate it!

Average rating 3.7 / 5. Vote count: 6

No votes so far! Be the first to rate this post.

Similar articles you may like

By Sunil Pradhan

Hi there 👋 I am a front-end developer passionate about cutting-edge, semantic, pixel-perfect design. Writing helps me to understand things better.

Leave a comment

Your email address will not be published. Required fields are marked *

Exit mobile version