dtrz99313 2013-07-02 17:38 采纳率: 100%
浏览 18

我是否需要CSS中的新行? [重复]

This question already has an answer here:

I know this is probably a trivial question, but I couldn't find anything on Google.

Is there any point in CSS where it's required to have a new line? For example, I have the following block of code:

#headertitle {
background: -o-linear-gradient(left,  #3fd0e4 0%,#18709f 100%); /* Opera 11.10+ */
background: linear-gradient(to right,  #3fd0e4 0%,#18709f 100%); /* W3C */
width:950px;
height:150px;
font-family:rw_SegoePrint_bold,'Segoe Print',OpenSansRegular,Verdana,sans-serif;
font-size:140px;
text-align:center;
position: absolute;
left: 50%;
top: 10px;
margin-left:-475px;
z-index:2;
}

I can simply remove the new lines to end up with #headertitle{background:-o-linear-gradient(left, #3fd0e4 0%,#18709f 100%);background: linear-gradient(to right, #3fd0e4 0%,#18709f 100%);width:950px;height:150px;font-family:rw_SegoePrint_bold,'Segoe Print',OpenSansRegular,Verdana,sans-serif;font-size:140px;text-align:center;position:absolute;left:50%;top:10px;margin-left:-475px;z-index:2;} and it still parses perfectly, as I would've expected. However, are there any instances in CSS coding that definitely require a new line to be present? Or am I okay to just replace " " with "" (using PHP)?

</div>
  • 写回答

4条回答 默认 最新

  • doujiao1981 2013-07-02 17:40
    关注

    Either way is correct. The former is better for development purposes because it is readable. The latter is better for production purposes as it results in a smaller file size, especially if you remove all the unnecessary spaces.

    评论

报告相同问题?