-3

enter image description hereI've been using prettier for 1 month and everything is fine. However, I have a code that when I write it, Prettier formats it in a different way and when I go to validate the code, it throws me a "slash and tray" error, any suggestions?

Screenshot

i try some youtube tutorials on setting up prettier, but that didnt work

1 Answers1

1

The error message "Trailing slash on void elements has no effect" typically occurs when using HTML self-closing void elements with a trailing slash ("/") at the end. Void elements in HTML, such as <img>, <input>, and <br>, do not require a closing tag and should not have a trailing slash. For example, if you have code like this:

<img src="image.jpg" />

Prettier may format it as:

<img src="image.jpg">

To resolve this issue, you can simply remove the trailing slash on void element (like in the second source sample above)

Btw if you don't need that specific check you can overwrite it in your .prettierrc or prettier.config.js file.

e.g.

module.exports = {
  overrides: [
    {
      files: '*.html',
      options: {
        ...
        // Add the rule you want to disable
        htmlVoidTags: false,
      },
    },
  ],
};