开发者

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 <开发者_JAVA技巧;style> element.

Is this OK with browsers?


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.


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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜