开发者

Which style of CSS formatting you would prefer to use if we are using Version control?

开发者 https://www.devze.com 2023-04-12 01:31 出处:网络
I\'m going to use version control first time and I read somewhere that Single line CSS is not a good idea for version control

I'm going to use version control first time and I read somewhere that Single line CSS is not a good idea for version control

.footer li h3 { margin: 0 0 6px; font-weight: bold; display: inline; color: #e92e2e; }
.footer li h3 a { font-weight: normal; font-size: 1em; color: #e92e2e; }

Which format you would prefer?

Is this below formatting good to use with version control

.footer li h3 {
    margin: 0 0 6px;
    font-weight: bold;
    display: inline;
    color: #e92e2e; }

    .footer li 开发者_运维百科h3 a {
        font-weight: normal;
        font-size: 1em;
        color: #e92e2e; }


From a standpoint of readability, Yes, the formatting you show makes more sense on multiple-lines because you'll be able to easily see the difference between 2 versions if a new attribute is added.


If you're working with other people on the same code, readability is the #1 most important thing you should focus on in your code (aside from making the code work, of course). A close second is using comments EVERYWHERE. This is just my opinion, of course some people might prefer comments over readability. Even if you're not working with anybody else, it's still very important to write readable code, in case another developer takes over the project in the future.

To answer your question, I prefer the second format, and I guess that most programmers would agree.


In Git you can easily do a word diff and quickly find changes within a line.

What you should really be looking at is making sure the CSS is readable. Use the format that your team is comfortable with. Make sure everyone does the same. See what the CSS community does. I don't think a version control system should be the reason you choose a format.

And of course, if you want compressed / minified CSS ( which is not exacly what you are asking ), it has to be part of build process and the file checked in should not be minified

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号