Single-line vs multi-line CSS formatting

前端 未结 5 1094
耶瑟儿~
耶瑟儿~ 2021-01-21 04:36

Though it\'s debatable, I\'ve heard the majority of CSS developers prefer multi-line because of the ease of which a property can be found within the CSS file. But doesn\'t this

5条回答
  •  后悔当初
    2021-01-21 05:21

    It's all a matter of preference based on what your team decides on. However, here's my take on why I use single-line formatting:

    When I need to maintain CSS, I'm most often looking to modify an existing selector. If the start of every line is a new selector, and not just more style declarations, it makes it easier to scan the document for the selector I want to find. It also means less scrolling to find what I need.

    Once I've found the selector I need to edit, good syntax highlighting makes it easy to read the rules for a specific selector, so I don't lose any readability by having all of my style declarations on a single line.

    That being said, I wouldn't say it helps with file size any. I rely on YUI Compressor to compress my CSS for me automatically, rather than trying to manually maintain an efficiently declared style document.

提交回复
热议问题