Single-line and multi-line CSS formatting

Although it's debatable, I heard that most CSS developers prefer a multi-line line because of the simplicity that a property can be found in a CSS file. But doesn't that make the CSS file bigger and less readable overall? I think a single line makes it faster to scan a CSS file. Any thoughts?

+3
source share
5 answers

It all depends on what your team decides. However, here I take on the question of why I use single-line formatting:

When I need to support CSS, I most often want to modify an existing selector. If the beginning of each line is a new selector, not just a style declaration, this makes it easier to scan the document for the selector I want to find. It also means less scrolling to find what I need.

As soon as I find the selector, I need to edit, good syntax highlighting will make it easier to read the rules for a particular selector, so I do not lose readability, having all my style declarations on one line.

Saying this, I would not say that it helps with file size. I rely on the YUI Compressor to compress my CSS for me automatically, rather than trying to manually maintain an efficiently declared style document.

+6
source

CSS- IMO , . .

CSS, minify/ .

, , CSS W3C CSS Test Suites.

+6

- , , . .

+1

, , .

CSS minifier, . CSS minifiers, .

YUI - .

+1

Like JavaScript code, you want to format your CSS to fit your team’s standard and let the compressor shorten it for deployment.

0
source

Source: https://habr.com/ru/post/1735862/


All Articles