Same for me, I managed to solve it with:

    {
        "editor.formatOnSave": true,
        "editor.formatOnPaste": true,
        "editor.formatOnType": true,
        "editor.defaultFormatter": "esbenp.prettier-vscode",
        "[html]": {
            "editor.defaultFormatter": "vscode.html-language-features"
        }
    }

This allowed me to use prettier globally and use built in html formatter for html. Also allowed the formatting to happen on save and while typing.

The part responsible for Prettier formatting html:

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

To open type Ctrl+Shift+P, then type open user/workspace settings JSON in the command line.

Answer from Eslam Sameh Ahmed on Stack Overflow
🌐
Reddit
reddit.com › r/vscode › prettier extension not working on html files
r/vscode on Reddit: Prettier extension not working on HTML files
January 29, 2022 -

I have Prettier setup as the default formatter already and it's working fine for JSX and JS files.

The weird thing is that it works on save, so when I save it formats HTML correctly, but if I try to do it manually I get: "Extension 'Prettier - Code formatter' is configured as formatter but it cannot format 'HTML'-files".

🌐
GitHub
github.com › prettier › prettier-vscode › issues › 2478
Prettier not used on HTML even though its the default formatter · Issue #2478 · prettier/prettier-vscode
March 24, 2022 - I have to explicitly set the default formatter for HTML in my workspace settings to prettier for it to work.
Published   Mar 24, 2022
🌐
GitHub
github.com › prettier › prettier-vscode › issues › 3241
Prettier-VSCode doesn't format selections in HTML documents · Issue #3241 · prettier/prettier-vscode
December 20, 2023 - Summary When formatting html files with prettier-vscode configured as html-formatter, the VSCode command "Format selection" does not work. The command "Format Document" works as expected. Github Repository to Reproduce Issue issue-repo S...
Published   Dec 20, 2023
🌐
GitHub
github.com › prettier › prettier-vscode › issues › 646
HTML Suddenly formatting improperly · Issue #646 · prettier/prettier-vscode
October 21, 2018 - Prettier is suddenly formatting html in a strange way, adding closing slashes to <hr> elements, dropping brackets/carats to the next line, leaving single > on their own line.
Published   Nov 20, 2018
🌐
Stack Overflow
stackoverflow.com › questions › 71655521 › prettier-not-formatting-html-in-visual-studio-code › 71657987
Prettier not formatting HTML in Visual Studio Code - Stack Overflow
On the other hand you could try using the default formatter rather than the prettier extension. Right click --> Format Document with... --> HTML Language Features ... Sign up to request clarification or add additional context in comments.
🌐
Prettier
prettier.io › docs › ignore.html
Ignoring Code · Prettier
A JavaScript comment of // prettier-ignore will exclude the next node in the abstract syntax tree from formatting. ... <!-- prettier-ignore --> <div class="x" >hello world</div > <!-- prettier-ignore-attribute --> <div (mousedown)=" onStart ( ) " (mouseup)=" onEnd ( ) " ></div> <!-- prettier-ignore-attribute (mouseup) --> <div (mousedown)="onStart()" (mouseup)=" onEnd ( ) " ></div>
Find elsewhere
🌐
Reddit
reddit.com › r/vscode › prettier not formatting css
r/vscode on Reddit: Prettier not formatting css
September 24, 2024 -

Hey everyone, for the life of me I can't figure out why prettier won't format css. I have gone over all of my setting, format on save, setting prettier as the default format, and checked the setting.json file. Still can't figure out what is going on. Any help would be appreciated!

🌐
Prettier
prettier.io › docs › options
Options · Prettier
When Prettier identifies cases where it looks like you've placed some code it knows how to format within a string in another file, like in a tagged template in JavaScript with a tag named html or in code blocks in Markdown, it will by default try to format that code. Sometimes this behavior is undesirable, particularly in cases where you might not have intended the string to be interpreted as code.
🌐
GitHub
github.com › prettier › prettier-vscode › issues › 2469
Not formatting html tags correctly, splits html tags on several lines · Issue #2469 · prettier/prettier-vscode
February 2, 2022 - ["INFO" - 16:26:57] Prettier Options: { "arrowParens": "always", "bracketSpacing": true, "endOfLine": "lf", "htmlWhitespaceSensitivity": "css", "insertPragma": false, "jsxBracketSameLine": false, "jsxSingleQuote": false, "printWidth": 120, "proseWrap": "preserve", "quoteProps": "as-needed", "requirePragma": false, "semi": true, "singleQuote": true, "tabWidth": 2, "trailingComma": "es5", "useTabs": false, "vueIndentScriptAndStyle": false, "filepath": "c:\\Users\\user\\AppData\\Roaming\\Code\\User\\settings.json", "parser": "json" } ["INFO" - 16:26:57] Formatting completed in 0.009ms.
Published   Mar 15, 2022
🌐
Prettier
prettier.io › blog › 2018 › 11 › 07 › 1.15.0.html
Prettier 1.15: HTML, Vue, Angular and MDX Support · Prettier
November 7, 2018 - Prettier uses filename to infer which parser to use. Here's the default patterns for HTML, Vue, and Angular: ... Make sure your filename matches the correct parser (especially for Angular users); if it does not, you will have to manually specify which parser to use via the overrides field. Note that framework-specific formatting won't be triggered in --parser html.
🌐
GitHub
github.com › prettier › prettier › issues › 4643
Unable to format HTML files, is this normal? · Issue #4643 · prettier/prettier
January 22, 2018 - What steps will reproduce the problem? command+shift+option+p on an html file What is the expected result? Format HTML/Markup What happens instead? This error: Prettier: File index.html has unsuppo...
Published   Jun 06, 2018
🌐
Reddit
reddit.com › r/vscode › prettier not working as intended? (html formatting)
r/vscode on Reddit: Prettier not working as intended? (HTML formatting)
July 31, 2024 -

So, I'm starting to learn web dev, I'm at HTML right now, and using Linux.

The problem I'm having, is no matter what I tinker with in Prettier's settings, the formatting does behaviors I don't like, that mess with my ability to check visually and compare with the video tutorial (2022) I'm using, just a single line break being added or deleted makes it look like everything and anything could be different from the source video.

These behaviors include:

  1. Deleting line break before <head> and after </body> tags.

  2. Indenting head and body tags, instead of just their contents.

  3. Adding a line break inside a <li> element and indenting it because it contains a phrase having <a> and <abbr> tags, the closing </abbr> also gets a line break right before the '>' (apparently abbr tag is "breaking" because it has a period right after). 🤦🤦🤦

I have set set the Print Width to 600 but it doesn't fix the 3rd problem.

Is there a VS Code feature that's just limited to adding indentation on format without messing with anything else? I'd like to know if there are fixes without having to disable Prettier if possible, but this is so ridiculous I may as well stop using it.

🌐
GitHub
github.com › prettier › prettier-vscode › issues › 1839
Extension 'Prettier - Code formatter' cannot format .... · Issue #1839 · prettier/prettier-vscode
March 15, 2021 - Summary Even I set format on save and prettier as a default formatter, when I save my code it isn't fixed. It shows error 'Extension 'Prettier - Code formatter' cannot format ....' Github Repository to Reproduce Issue https://github.com/...
Published   Mar 15, 2021
🌐
GitHub
github.com › prettier › prettier-vscode › issues › 636
Add the missing option to disable crappy Prettier VSCode HTML formatter · Issue #636 · prettier/prettier-vscode
October 13, 2018 - Latest version of Prettier - Code formatter [1.7.0] makes crappy HTML formatting when VSCode Format on Save is active. Please, either allow through the Prettier VSCode settings to disable its bad H...
Published   Nov 13, 2018
🌐
SheCodes
shecodes.io › athena › 8760-troubleshooting-prettier-formatter-not-working-after-restarting-vs-code
[VS Code] - Troubleshooting Prettier Formatter Not Working After Restarting VS Code
Learn how to resolve the issue of Prettier formatter not working even after restarting Visual Studio Code with these troubleshooting tips. ... when I try to use Visual Studio Vode, I save my index.html, and when I click twice, and I type my code, nothing appears on my index.html, anyone knows why?