Skip to content

[CSS] Don’t combine multiple selectors onto same line #2057

Closed

Description

@keithjgrant

Right now, Prettier merges multiple selectors into the same line if space allows:

.foo,
.bar,
.baz {}

becomes:

.foo, .bar, .baz {}

I don’t think this behavior jives with the way most people write CSS. It is both my preference and, I think, more common to always separate selectors onto their own lines, regardless of length. This helps when scanning a file visually for a particular selector, so .foo, .bar isn’t mis-read as .foo .bar.

Additional support for this reasoning: reading through the Bootstrap source, they keep selectors separate, regardless of length, in almost every instance. The Foundation framework also follows this practice for the most part, though it’s a little less consistent.

Activity

  1. keithjgrant commented on Jun 8, 2017

    @keithjgrant
    Author

    BTW, thanks for the CSS support. This is awesome! 😃

  2. vjeux commented on Jun 8, 2017

    @vjeux
    Contributor

    I just merged @yuchi's PR to fix this! #2047 In the next release of prettier it'll always print them line by line.

  3. added
    locked-due-to-inactivity
    on Jul 7, 2018
  4. locked as resolved and limited conversation to collaborators on Jul 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    locked-due-to-inactivity

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions