'Visual Studio Code 1.42 is changing <br> to <br /> on format

This recently started happening. I’m not sure what changed but maybe because I tried to activate Preitter extension. I’m new to Visual Studio Code. I’m working on HTML5 documents. When I save with ctrl+s my indentations are lined up nicely but all of my

<br> 
are changed to 
<br />

I read that this is XHTML formatting. I’m not using XHTML and would like to stop this from happening. I saw a similar question from seven years ago, but the answers were not relevant to the version of Visual Studio Code that I’m using.



Solution 1:[1]

I made the settings.json file look like this:

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

and now it's working again. Before the change it had the Prettier extension listed for HTML. Perhaps this was creating a conflict. I'm going to confirm, in the meantime I wanted to answer my own question in case someone has the same issue.

Solution 2:[2]

setting

Turn off above setting then restart Visual Studio Code.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 kavise
Solution 2 4b0