Bookmark/Search this post with:
Thursday, March 13, 2008
On the #drupal IRC channel, Excallibur points out that there are no coding standards for CSS. I’d like to propose some straightforward ones.
Note that I am not intentionally omitting indentation within rules, but am having trouble with my code filter.
I. CSS is not Java.
This java-style of CSS does not make the code easier to read:
It just adds an unnecessary space. Below is the correct way, which is consistent with core CSS.
II. Two selectors = Two lines.
While the following code is more compact, it’s also more difficult to scan.
The right way is separate lines.
This small rule can make a big difference in complex themes (ever tried to debug some old civicspace themes?).
III. Single Line Rules
Single line rules are acceptable when there is only one selector and one property.
Can you think of any others? Disagree?