βӔḺṪẶⱫŌŔ
βӔḺṪẶⱫŌŔ

Reputation: 1296

Can you add line-breaks within CSS rules?

I know 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.

Upvotes: 1

Views: 103

Answers (3)

dbyuvaraj
dbyuvaraj

Reputation: 505

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

Upvotes: 1

iain
iain

Reputation: 1935

CSS has no significant white space.

However, your last block should not have commas.

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

This would work.

Upvotes: 5

lpd
lpd

Reputation: 2347

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

(In other words, yes and yes.)

Upvotes: 8

Related Questions