Solution:

In order to allow single-line blocks in VSCode using Prettier - Code formatter extension, please take the following steps:

  1. Enable stylelint integration by adding this in the VSCode Settings (JSON): "prettier.stylelintIntegration": true
  2. Install stylelint and stylelint-prettier npm modules in your project directory. npm install stylelint stylelint-prettier --save-dev
  3. Add a .stylelintrc.json file at the root of your project directory with the following code:
    {
        "plugins": ["stylelint-prettier"],
        "rules": {
            "block-closing-brace-newline-after": "always-multi-line",
            "block-closing-brace-empty-line-before": "never",
            "block-closing-brace-space-before": "always",
            "block-opening-brace-space-after": "always",
            "block-opening-brace-space-before": "always",
            "block-closing-brace-newline-before": "always-multi-line",
            "block-opening-brace-newline-after": "always-multi-line",
            "indentation": 4
        }
    }

You can add/customize more stylelint rules, see the entire list of rules here.

Took me a while to understand how to configure these options, if you're starting out with stylelint, I highly recommend you read its guidelines first.

Answer from Arslan Akram on Stack Overflow
🌐
Prettier
prettier.io
Prettier · Opinionated Code Formatter · Prettier
Try It OnlineInstall Prettier · Limited edition tshirts are now available to buy! $10 per tshirt goes to maintain the project. An opinionated code formatter · Supports many languages · Integrates with most editors · Has few options » · Your code is formatted on save · No need to discuss style in code review · Saves you time and energy · And more » · JavaScript · JSX · Flow · TypeScript · JSON · CSS ·
Blog
We're excited to announce that Prettier now fully supports the fresh features landing in Angular v21.1 (released today 🎉) · This update brings cleaner, more expressive templates with:
Options · Prettier
For example, the following will use the CSS parser: ... This option is only useful in the CLI and API. It doesn’t make sense to use it in a configuration file. ... Prettier can restrict itself to only format files that contain a special comment, called a pragma, at the top of the file.
Configuration File
Otherwise you effectively disable Prettier’s automatic file extension based parser inference. This forces Prettier to use the parser you specified for all types of files – even when it doesn’t make sense, such as trying to parse a CSS file as JavaScript.
🌐
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!

🌐
FreeFormatter
freeformatter.com › css-beautifier.html
Free Online CSS Beautifier / Formatter - FreeFormatter.com
This free online tool lets you beautify/format your CSS code with no side effects
🌐
GitHub
github.com › prettier › prettier
GitHub - prettier/prettier: Prettier is an opinionated code formatter. · GitHub
JavaScript · TypeScript · Flow · JSX · JSON CSS · SCSS · Less HTML · Vue · Angular GraphQL · Markdown · YAML Your favorite language? Prettier is an opinionated code formatter.
Starred by 51.8K users
Forked by 4.7K users
Languages   JavaScript 83.3% | TypeScript 6.2% | CSS 3.0% | HTML 3.0% | SCSS 1.5% | Less 1.0%
🌐
Visual Studio Marketplace
marketplace.visualstudio.com › items
Prettier - Code formatter - Visual Studio Marketplace
January 21, 2026 - Extension for Visual Studio Code - Code formatter using prettier
🌐
Prettier
prettier.io › docs
What is Prettier? · Prettier
Prettier is an opinionated code formatter with support for: JavaScript (including experimental features) JSX · Angular · Vue · Flow · TypeScript · CSS, Less, and SCSS · HTML · Ember/Handlebars · JSON · GraphQL · Markdown, including ...
🌐
JetBrains
jetbrains.com › help › webstorm › prettier.html
Prettier | WebStorm Documentation
Prettier is a tool to format files in various languages, like TypeScript, JavaScript, CSS, HTML, JSON, and others. With WebStorm, you can format selected code fragments as well as entire files or directories using the Reformat with Prettier action.
Find elsewhere
🌐
CSS-Tricks
css-tricks.com › prettier-beautify
Prettier & Beautify | CSS-Tricks
November 20, 2018 - Prettier is an “opinionated code formatter.” I highly suggest using it.
🌐
Aiimi
aiimi.com › insights › using-eslint-prettier-and-stylelint-for-insightmakers-front-end
Using ESLint, Prettier & Stylelint for front-end code - Aiimi
October 6, 2020 - Prettier: Prettier is an ‘opinionated code formatter’ that supports a wide range of languages and formats them according to a set of defined rules. We use Prettier for HTML exclusively. Stylelint: What ESLint is to JavaScript, Stylelint is to CSS.
🌐
Kirby Forum
forum.getkirby.com › the cms › questions
Prettier configuration for Tailwind CSS and Kirby CMS - Questions - Kirby Forum
July 31, 2023 - I want to use Tailwind’s class sorting plugin for Prettier but I need to set up a .prettierignore file and I’m not really familiar with the gitignore syntax or what files I should ignore? I’m guessing I should ignore all of the files except for Kirby’s template, snippet related files?
🌐
Ben Frain
benfrain.com › use-linters-for-errors-formatters-to-fix-style
Use linters for errors, formatters to fix style – Ben Frain
May 10, 2017 - In short, any downsides have been greatly outnumbered by the positive and when I jump into TypeScript, I really miss having prettier to tidy things up as I go. So, for CSS, I’m now using a formatter for stylistic preference and a linter to point out potential errors.
🌐
Ben Frain
benfrain.com › prettier-install-and-configuration-because-manually-formatting-front-end-code-is-a-waste-of-time
Prettier install and configuration — because manually formatting front-end code is a waste of time
March 6, 2021 - I’ve been using Prettier for about four years now and it’s been a game changer. If you haven’t tried it yet, I can’t wait to hear how you like it. ... If you enjoyed this post and/or it was useful, Say thanks with a coffee. 🙏 Support me on Kofi ... Write and maintain large scale modular CSS and embrace modern tooling including PostCSS, Stylelint and Gulp
🌐
CleanCSS
cleancss.com › css-beautify
CSS Formatter
Enter your messy, minified, or obfuscated CSS Style Sheets into the field above to have it cleaned up and made pretty. The editor above also contains helpful line numbers and syntax highlighting.
🌐
Prettier
prettier.io › blog › 2017 › 06 › 03 › 1.4.0
Prettier 1.4: TypeScript and CSS support · Prettier
June 3, 2017 - This release introduces support for TypeScript, CSS, Less, and SCSS languages to Prettier!