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

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

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.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Similar articles you may like

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.

Add comment

Stay Updated

Want to be notified when our article is published? Enter your email address below to be the first to know.

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.