Šime Vidas
Šime Vidas

Reputation: 186003

Can I use an HTML <style> element without line-breaks?

<style>/* foo */ body{color:red}div{color:green}</style>  

So, I have this <style> element. It has a comment, and then several CSS rules. It is my CSS reset code, so I would like to have it in one line, without a single line break inside the <style> element.

Is this OK with browsers?

Upvotes: 2

Views: 198

Answers (2)

BoltClock
BoltClock

Reputation: 724252

Sure it is. Whitespace is insignificant in CSS except in at-rules, as the descendant combinator, and when using it to separate property values (e.g. in shorthand properties), among other things.

The CSS2.1 syntax documentation talks about the effect of whitespace (or lack thereof) on your CSS code.

Upvotes: 2

Phrogz
Phrogz

Reputation: 303411

Yes (provided you include proper attributes on your <style> element :).

Upvotes: 0

Related Questions