开发者

Can you add line-breaks within CSS rules?

开发者 https://www.devze.com 2023-03-02 07:16 出处:网络
I kn开发者_如何学Goow that generally, you’d write something like this: .Something { other: thing;

I kn开发者_如何学Goow that generally, you’d write something like this:

.Something {
  other: thing;
}

etc. But, is it okay to instead of having a space after :, to have a new line, like the following?

.Something {
  background-color:
    #161616;
}

And for other things, something like this?

.Something {
  padding:
    5px,
    2px,
    2px,
    13px;
}

I’m just getting really tired of clucking everything on a single line, and just want to know if this is syntactically valid. I am still reading over the W3C pages now, but still haven’t found an answer.


CSS is completely ignorant of white space, format it as you please :)

(In other words, yes and yes.)


CSS has no significant white space.

However, your last block should not have commas.

.Something {
 padding:
 5px
 2px
 2px
 13px;
}

This would work.


ya you can use like this.

.Something {
 background-color:
 #161616;
}

this is syntatically correct and it worked for me. I used like this before.

And why are you putting ',' for the second one like below

.Something {
 padding:
 5px,
 2px,
 2px,
 13px;
}

The ',' should not be used for separate the values. you can use space instead.

The only thing in both the cases is It should ends with semicolon

0

精彩评论

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