Showing results for prettier css formatting
Search instead for prettier scss formatting

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: Consecutive @case statements in @switch blocks. Spread elements (...) in array literals, object literals, and function calls inside templates. We've also added the ability to format ...
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
You can configure Prettier via (in order of precedence):
Discussions

[CSS] single line property formatting
I am re-raising this issue. I am currently working on a CSS utility library. Almost all the classes have a single CSS property, yet they are all formatted by Prettier to take up multiple lines. For a single property, this is a massive wa... More on github.com
🌐 github.com
78
January 16, 2019
How to format/prettier css handlebars file
Editor: VS Code Theme: 3rd party I open a file called bundle-css.hbs and it looks like a jumbled mess. I’d like to format/prettier it so it’s easier on the eyes to edit. Things I’ve tried: –installed handlebars formatter extension in VS Code – VS Code | Preferences | files association ... More on forum.ghost.org
🌐 forum.ghost.org
1
0
October 6, 2021
Prettier is not formatting css files that include @apply
Prettier is formatting my module.css files that uses tailwind classes strangely. Expected: ``` .foo { @apply border-2 rounded } Actual (the first style is moved next to @apply and a ; is added to t... More on github.com
🌐 github.com
2
October 7, 2021
Prettier not formatting css
Is your file a .css with just working (not broken) css in it? More on reddit.com
🌐 r/vscode
11
0
September 24, 2024
🌐
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
Setting max_line_length in an .editorconfig file will configure Prettier’s print width, unless overridden. (If you don’t want line wrapping when formatting Markdown, you can set the Prose Wrap option to disable it.)
🌐
Prettier
prettier.io › blog › 2017 › 06 › 03 › 1.4.0
Prettier 1.4: TypeScript and CSS support · Prettier
June 3, 2017 - You can just drag in the rough place where the code you want to reformat it, and it's going to! Since we are now formatting CSS and TypeScript, it is not convenient to have to specify the parser for every file.
🌐
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
🌐
GitHub
github.com › prettier › prettier › issues › 5948
[CSS] single line property formatting · Issue #5948 · prettier/prettier
January 16, 2019 - e.g. here is some code from the relatively popular [Tachyons library](e.g.: https://github.com/tachyons-css/tachyons/blob/master/css/tachyons.css): .mt0 { margin-top: 0; } .mt1 { margin-top: .25rem; } .mt2 { margin-top: .5rem; } .mt3 { margin-top: 1rem; } .mt4 { margin-top: 2rem; } .mt5 { margin-top: 4rem; } .mt6 { margin-top: 8rem; } .mt7 { margin-top: 16rem; } Here's is what it looks like after using Prettier:
Author   o-t-w
Find elsewhere
🌐
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
🌐
Ghost Forum
forum.ghost.org › developer help
How to format/prettier css handlebars file - Developer help - Ghost Forum
October 6, 2021 - Editor: VS Code Theme: 3rd party I open a file called bundle-css.hbs and it looks like a jumbled mess. I’d like to format/prettier it so it’s easier on the eyes to edit. Things I’ve tried: –installed handlebars formatter extension in VS Code – VS Code | Preferences | files association ...
🌐
GitHub
github.com › prettier › prettier-vscode › issues › 117
Prettier doesn't format *.css and *.scss files. · Issue #117 · prettier/prettier-vscode
"prettier.eslintIntegration": true, "prettier.singleQuote": true, "prettier.printWidth": 80, "prettier.trailingComma": "all", "prettier.cssEnable": [ "css", "less", "sass" ], But there is no "Format document" option in the content menu in vscode for *.css and *.scss files.
Author   ghost
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-format-code-with-prettier-in-visual-studio-code
Format Code with Prettier in Visual Studio Code: Setup Guide | DigitalOcean
August 1, 2025 - Learn how to format code with Prettier in Visual Studio Code. This guide walks you through installing, configuring, and using Prettier for code formatting.
🌐
Prettier
prettier.io › docs › configuration
Configuration File · Prettier
For example, to get Prettier to format its own .prettierrc file, you can do:
🌐
Medium
thiraphat-ps-dev.medium.com › how-to-use-prettier-to-format-your-code-a-comprehensive-guide-6baad28c383d
How to Use Prettier to Format Your Code: A Comprehensive Guide | by Thiraphat Phutson | Medium
June 5, 2024 - Writing clean, consistent, and readable code is crucial for maintaining a high-quality codebase. Prettier is a powerful code formatter that helps developers achieve this by automatically formatting their code according to a set of predefined rules.
🌐
GitHub
github.com › prettier › prettier
GitHub - prettier/prettier: Prettier is an opinionated code formatter. · GitHub
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
Starred by 51.7K 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%
🌐
GitHub
github.com › prettier › prettier-vscode › issues › 2234
Prettier is not formatting css files that include @apply · Issue #2234 · prettier/prettier-vscode
October 7, 2021 - .prettierrc or .editorconfig), VS Code configuration will not be used ["INFO" - 4:12:25 PM] Prettier Options: { "filepath": "/src/components/Card/Card.module.css", "parser": "css", "trailingComma": "none", "semi": false, "singleQuote": true, "arrowParens": "always", "printWidth": 120 } ["INFO" - 4:12:25 PM] Formatting completed in 0.01ms.
Author   grantspilsbury
🌐
Prettier
prettier.io › blog › 2018 › 02 › 26 › 1.11.0.html
Prettier 1.11: CSS fixes and new TypeScript feature support · Prettier
February 26, 2018 - This release features a ton of CSS formatting fixes as well as support for some new TypeScript features, in addition to some general bugfixes for other languages. Since the last release, the Prettier website has gotten an all-new design thanks to @orta!
🌐
Testmu
testmu.ai › home › free tools › css prettify online
CSS Prettify Online Tool | TestMu AI
... CSS code can be made prettier to make it simpler to read and comprehend. It entails consistently and logically formatting the code, for as by indenting nested components and adding white space.
🌐
Projectwallace
projectwallace.com › blog › tiny-css-formatter
Building a lightweight CSS formatter - Blog - Project Wallace
June 7, 2023 - Because we have a DevTools panel now on the analyzer page, it makes sense to view the CSS usage in a formatted manner. But this came at a cost: prettifying the CSS took up to twice as long analyzing the CSS! Time to look at a more performant alternative. CSS that is being audited where the source code was originally minified, making the auditing process difficult, because those lines become pretty much unreadable. The first iteration of our prettifier used Prettier, a very popular and respectable project that can pretty-print hundreds of different languages.