CSS Coding Standards

Hi all,
I'm at the documentation sprint.
I would like to propose some CSS coding standards, to accompany the PHP coding standards, along with the proposed Javascript standards.

I've added a handbook page at
http://drupal.org/node/302199
Discussion should be in this thread, and the handbook page updated as necessary.

Stella, the Coder module maintainer, has promised to add this to Coder module, once the dust settles on the dissussion.

Login to post comments

Thanks Nick!

alanburke - Sun, 2008-08-31 11:21

First up,
Thanks to Nick Lewis for kicking this off at
http://www.nicklewis.org/node/966.

The standards are slightly different to those he prosposed.

For the most part, the standards describe how core css files currently function.
The main expection is that I propose a single line between each rule, to aid readability.

I do realise that just adding a standards page, without prolonged discussion, is perhaps controversial.

I don't anticpate changing Drupal 6 core css files at all.

Hopefully we will reach some agreement,
then the rules can be added to the Coder module for Drupal 7.
Once that happens, we can create patches, if necessary, for core files.


Update - May also apply to Drupal 6

alanburke - Sun, 2008-08-31 11:50

Myself and Stella spoke to Gabor.

Stella intends to add the CSS and Javascript rules to Drupal 6 version of coder.

Once that happens we can work on patches for core.

In principle, Gabor agrees that changing core css code to comply with coding standards does not constitute an API change [even if the standards were added retrospectively].

So these standards may yet apply to core for Drupal 6.


I'm not a huge fan of the

Morbus Iff's picture
Morbus Iff - Sun, 2008-08-31 12:09

I'm not a huge fan of the "multiple selectors must be on one line". Very long selectors could make that line hundreds of lines long. Something like, for example:

#casetracker-status-cant-reproduce td.sorted.odd, #casetracker-status-resolved td.sorted.odd, #casetracker-status-needs-work td.sorted.odd, [etc.] {

versus:

#casetracker-status-cant-reproduce td.sorted.odd,
#casetracker-status-resolved td.sorted.odd,
#casetracker-status-needs-work td.sorted.odd {


Gah, posted before I wanted

Morbus Iff's picture
Morbus Iff - Sun, 2008-08-31 12:10

Gah, posted before I wanted to (usability problem: I /expect/ a Preview button because I don't "see" the live Preview). Anyways, I'd want it both ways: small selectors can be placed on one line, but very large ones like the above should be split for readability's sake.


+1

sun.core's picture
sun.core - Sun, 2008-08-31 14:41

...however, hard time to find a rule for this, because what's a long line? Exceeding 80 chars?

Daniel F. Kudwien
unleashed mind


hundreds of lines

xurizaemon's picture
xurizaemon - Mon, 2009-11-23 21:36

according to Morbus's comment above, a very long line can be hundreds of lines long ;>


One line is a terrible

tjholowaychuk - Sun, 2008-08-31 17:18

One line is a terrible standard, I vote no to that as well... Please remember we DO have CSS minification, whitespace is irrelevant, readability is much more important .

Tj Holowaychuk

Vision Media - Victoria BC Web Design
Victoria British Columbia Web Design School


I agree

mike stewart's picture
mike stewart - Mon, 2008-09-01 18:04

readability is key. separate lines can be helpful in identifying typos, too.


Each property should end in

sun.core's picture
sun.core - Sun, 2008-08-31 18:15

Each property should end in a semi-colon.
[Even though this isn't strictly necessary for the last rule, it aids readability.]

Please remove that (too limited) justification in brackets. Just like the trailing comma in multi-line arrays in PHP, the standard also makes patches against existing code cleaner.

There should be a single empty line between rules.

-1 on this rule, because most stylesheets become unclear this way; however, +1 for separating related styles into "blocks" using one or two single empty lines between rules.
For example,

.foo-bar-baz .foobar .beer {
  margin: 0 0 2em 0;
}


.foo-bar-baz .foobar .beer div {
  overflow: hidden;
}


.baz-bar-foo .barfoo .beer {
  margin: 0 0 2em 0;
}


.foo-bar-baz .foobar .beer ul {
  overflow: hidden;
}

is harder to distinguish than blocks with related styles:
.foo-bar-baz .foobar .beer {
  margin: 0 0 2em 0;
}
.foo-bar-baz .foobar .beer div {
  overflow: hidden;
}
.foo-bar-baz .foobar .beer ul {
  overflow: hidden;
}


.baz-bar-foo .barfoo .beer {
  margin: 0 0 2em 0;
}

meh... the <code> filter does not properly display these empty lines and blocks. Hope you get the point anyway - a) group styles that belong together (i.e. apply on the same target, f.e. a block), and b) do not separate styles within one grouping block, but separate styles for different target elements or output objects with empty lines.

Daniel F. Kudwien
unleashed mind


I completely agree with

brenda003's picture
brenda003 - Tue, 2008-09-02 02:22

I completely agree with this. I don't think it aids readability to have a single line separator at all, actually. It just takes up more space on your screen. It actually seems to be very common right now to only use a single empty line separator for different "sections", though I can't swear on it, I'm sure that's how a few of the big themes (at least used to) do it.


Indentation

Zarabadoo - Sun, 2008-08-31 18:49

I have been finding indentation on related and nested blocks to provide better readability. I personally +1 the single space between declarations, but between distinct blocks I use comments. Multiline comments for the major blocks, and then single line comments for the tiny bits that need more explanation. Using the same example, it would be something like this:

/
* Styles for the beer within the foo-bar-baz
/
.foo-bar-baz .foobar .beer {
  margin: 0 0 2em 0;
}

  .foo-bar-baz .foobar .beer div {
    overflow: hidden;
  }

    /
The ul elements need some specific styles for this */
    .foo-bar-baz .foobar .beer ul {
      overflow: hidden;
    }

/

* The beer in the baz-bar-foo needs to be styled differently
*/
.baz-bar-foo .barfoo .beer {
  margin: 0 0 2em 0;
}

I find when there starts to be 1000+ lines of css to dig through, this comes in very handy.

Note: The spacing in the code element seems to be off.


agree with indentation

mike stewart's picture
mike stewart - Mon, 2008-09-01 18:18

yes, another nicety when it comes to readability. although some might argue this will make maintenance more difficult... but I think it definitely helps readability.

edit: ok, I probably should have read the whole thread before posting. but after reading everything in the thread, i still feel this aids readability, but don't feel as strongly about it. probably because much of my css reading comes through a parser such as firebug


I've never seen this used

brenda003's picture
brenda003 - Tue, 2008-09-02 02:23

I've never seen this used before, it looks very "wrong" to me.


This seems like a good idea,

Nick Lewis's picture
Nick Lewis - Tue, 2008-09-02 04:43

This seems like a good idea, that will go satanic in the wrong hands. The big worries for me is:
1. the indention will often not reflect reality, because of the laziness that we developers are prone to while writing css.
2. The format encourages bad practices, in some ways....

For example, say I wanted unique styles for blogs.... this format encourages me to do it like this....

body#blog {
color:#222222;
}
  #blog-page-title {
    font-size:1.5em;
  }
  .blog-links {
    font-size:1.3em;
  }
  h3.blog-title {
   font-size:1.1em;
  }

This is silly. I'm using indentation, instead of #ids, and document comments to delineate sections.
/*--------------- [ BLOG STYLES } ----------------- */
body#blog {
color:#222222;
}

body#blog #page-title {
    font-size:1.5em;
}

body#blog .links {
    font-size:1.3em;
}

body#blog .title {
   font-size:1.1em;
}

One could argue the latter is harder to read... but one cannot disagree that its closer to how a browser will actually interpret it. Who knows where an indented class actually may be used if someone isn't paying 100% attention to the classes and ids in their markup. At least by using unique #id's as "indentation" you ensure that the ID must be present for the style to apply.

Also, indented CSS bugs me personally in the same way as a java-style CSS does... e.g.

#content
{
  color:#000000;
}

It just looks wrong... and I can't work with the code until I fix ever last line of formatting... While its a matter of taste, arguably, we should allow nothing that freaks people out to the point where they have to reformat every line, or take a cocktail of tranquilizers before they are comfortable working with it....
++++++++++++++++++++++++++++++++
"I'm not concerned about all hell breaking loose, but that a PART of hell will break loose... it'll be much harder to detect." - George Carlin
++++++++++++++++++++++++++++++++
work: http://www.onnetworks.com
blog: http://www.nickewis.org


For clarification, the

Zarabadoo - Tue, 2008-09-02 16:02

For clarification, the indenting is intended for pieces that specifically require relationship to another element to take effect. So unless it is specifically linked to another element, it really should not be indented.

Discussing it any further though seems fruitless at this point though. I believe there are enough points against it to successfully take it out of the pool.

As for the comfort factor, it is inherent with standards that there are going to be people that do not like it. There are a few prominent people that do not like the Drupal PHP coding standards, and thus do not use them in their own modules. They suck it up when doing core work though, and that is where it really counts. I will probably end up doing a bit of the same thing when it comes to my goofball indenting on my own contrib themes.


+1 for removing the

Morbus Iff's picture
Morbus Iff - Sun, 2008-08-31 19:02

+1 for removing the "justification in brackets".

As for "There should be a single empty line between rules.", I'm also +1 to this (as opposed to sun). Sun seems to be using the "no lines between rules" as an indication of a "block" of CSS-related selectors. My opinion on that is: you can accomplish the block just as well, and far more clearly, with comments detailing what the block is. So I'm +1 to a single empty line, and would challenge Sun to clearly document his "blocks" (which I certainly agree with) with explicit comments, instead of inferred no-lines.


Well, 1) just like brenda

sun.core's picture
sun.core - Tue, 2008-09-02 13:49

Well,

1) just like brenda mentioned above, my point is that a CSS file gets unnecessarily cluttered if there are needless empty lines between styles (selectors).

2) Of course one should use comments to separate sections. However, one is able to use blank lines to visually separate sub-sections within a (commented) section, which do not need or justify additional comments.

3) We are also not cluttering PHP files with needless blank lines.

So in the end, I'm actually waiting for three counter-arguments instead of personal +1 votes on empty lines.

Daniel F. Kudwien
unleashed mind


I guess my main reason is

stella's picture
stella - Tue, 2008-09-02 14:02

I guess my main reason is that I find it easier to read CSS files if there's a blank line between rules, so for me readability is key here.


Readability?

sun.core's picture
sun.core - Tue, 2008-09-02 14:57

Hm. I cannot see a significantly better readability between:

.foo-bar-baz .foobar .beer {
  margin: 0 0 2em 0;
}

.foo-bar-baz .foobar .beer div {
  overflow: hidden;
}

.foo-bar-baz .foobar .beer ul {
  overflow: hidden;
}

and
.foo-bar-baz .foobar .beer {
  margin: 0 0 2em 0;
}
.foo-bar-baz .foobar .beer div {
  overflow: hidden;
}
.foo-bar-baz .foobar .beer ul {
  overflow: hidden;
}

All styles are separated by an almost (}) blank line anyway. IMHO, it just takes more space.

If we cannot find a consensus on this one, we should drop this rule.

Daniel F. Kudwien
unleashed mind


I personally find it much

Zarabadoo - Tue, 2008-09-02 15:50

I personally find it much easier to read. Plus that extra space would be taken out with compression.


I'm surprised, I don't find

brenda003's picture
brenda003 - Tue, 2008-09-02 16:37

I'm surprised, I don't find it easier to read at all. But it's not something I'm adamantly set against, it just creates more scrolling.


Quick repsonses

alanburke - Sun, 2008-08-31 19:23

Great to see some instant feedback!
[Addi was right! - Put it straight in the handbook - and people will talk!]

@Morbus
While I see some justification is being able to use both multiple selectors on one line,
but use multiple lines if necessary, I'd rather be consistent.

I propose single selector per line,
space follow by brace after the last selector.

I really like the single line between rules, and blocks of related rules should be commented.

How about a comment after the last line in a group of rules to indicate the end of that group?

In general, should the PHP comment guidelines also apply to CSS?
[I spoke to Neil Drumm - he is considering improving api.drupal.org to include js and css files too, btw].

Justification in brackets removed.

Alan


There is no reason CSS could

tjholowaychuk - Sun, 2008-08-31 19:41

There is no reason CSS could not use a JavaDoc-like syntax. I have not had time to work on my CSSDoc syntax specification however that was the goal..
This basic structure is what I use on all projects http://vision-media.ca/sites/all/themes/light/style.css

Laying out the stylesheet like really is quite logical and simplistic, should not be an issue for anyone to maintain. It is all about maintainability, readability, not saving space or performance.

Tj Holowaychuk

Vision Media - Victoria BC Web Design
Victoria British Columbia Web Design School


I also disagree with Nick's

tjholowaychuk - Sun, 2008-08-31 19:43

I also disagree with Nick's acceptance towards single-liners. Just because it may only have one rule at the moment does not mean it will stay that way, and most likely will not. So bumping down those lines is really just a hassle.

Tj Holowaychuk

Vision Media - Victoria BC Web Design
Victoria British Columbia Web Design School


Good point. The main reason

Nick Lewis's picture
Nick Lewis - Tue, 2008-09-02 04:20

Good point. The main reason I think its important, however, is that certain rules are in fact easier to read when written like that, consider headings:

h1 {1.8em;}
h2 {1.6em;}
h3 {1.4em;}
h4 {1.3em;}
h5 {1.2em;}
h6 {1.1em:}

vs.
h1 {
  1.8em;
}

h2 {
  1.6em;
}

h3 {
1.4em;
}

h4 {
  1.3em;
}

h5 {
  1.2em;
}

h6 {
1.1em:
}

Clearly, most people will prefer the first version. I think the great writing advice, "Sooner break the rules, then say something outright barbarous" applies to CSS. There are even cases where writing rules on a single line makes sense... for example a font declaration.
body {
font-family: "lucida grande", "lucida unicode", sans-serif";
}
h1, h2, h3, h4, h5, h6 {
font-family: "helvetica", sans-serif;
}

Vs.
h1,
h2,
h3,
h4,
h5,
h6 {
font-family: "helvetica", sans-serif;
}

Having the rules on the same line, in the former version, makes sense. The idea here is not be nazis about it to the point where our rules get in the way of sensible judgement. Rather, its to have standards to help avoid lines that look like this:
.highlight-text, input#some-field, #important-content, .grid-1a #content-type-secondary-content, #page-elements {font-size:24px; background-image:url(1111tb.png); float:left;}

++++++++++++++++++++++++++++++++
"I'm not concerned about all hell breaking loose, but that a PART of hell will break loose... it'll be much harder to detect." - George Carlin
++++++++++++++++++++++++++++++++
work: http://www.onnetworks.com
blog: http://www.nicklewis.org


True! I am not going to lie

tjholowaychuk - Tue, 2008-09-02 14:10

True! I am not going to lie h1-h6 I do put on a single line. I suppose the primary reason for caring less about it in that manor would be that rather than highly altering h1-h6 you would maybe:

#primary h1 {

}

etc. Tough call! but like you mention it does not look to pretty taking up a line each either. I guess the big problem is when it gets into having white space within the selector(s) that the one line becomes unwieldy.

Tj Holowaychuk

Vision Media - Victoria BC Web Design
Victoria British Columbia Web Design School


We could just not specify a

stella's picture
stella - Tue, 2008-09-02 14:58

We could just not specify a standard for this? Or maybe just have a vague one saying something like "multiple one word selectors can be all on one line but longer selectors should each be on their own line".

So anything that is one word, e.g. "h1", "h2", etc, in the above example would be on one line, but anything that requires 2 parts separated by a space would constitute a longer selector and would each have to be on a separate line.

Coder should be able to handle that, though someone would need to make sure the description for that rule in the docs is clearer!

It's just an idea, but it means we could avail of the benefits in each method.

Cheers,
Stella


Dictating Coding Patterns - Bad Idea

purrin's picture
purrin - Wed, 2008-09-03 22:55

I really feel compelled to share my opinion with this whole Drupal css "standards" issue - trying to dictate to designers and Web Standards-based web developers how to code out their CSS in their style sheets is a fool's errand. There are as many different personal preferences amongst the absolute best Designers working today in xhtml and CSS as their are good designers. For us to try to make an "official" way of doing it is just ridiculous. We should be concentrating on keeping the code as lean and bloat-free as possible in core and making the system as open to as many different preferences as possible - totally agnostic as far as coding styles go.

For example, apart from Drupal, the broader CSS design community has a number of high profile design advocates and evangelists, including Andy Clarke who is on the W3C's CSS 3 working group, who argues very much in favor of making CSS more readable and usable by keeping layout styles apart from fonts, and those two apart from colors... all in separate style sheets. I fear Drupal making itself even less accessible to those who are new to it by dictating a certain way of writing CSS.. We can not draw the top CSS design talent to the Drupal community by telling them how they must learn to type their code.

A good lesson, I think, is to be learned from Wordpress - its unimaginable success is due in large part to the very open, flexible way in which is deals with styles.... it makes no assumptions and dictates no patterns... and it does not bloat you code. I think that should be our mantra: lean, agnostic, and bloat-free.

-=- christopher

PS: this wasn't meant to be directed at anyone in particular.. I just jumped in and added my $0.02 arbitrarily..


Missing the point slightly

alanburke - Tue, 2008-09-09 20:58

http://groups.drupal.org/node/14421#comment-48105
attempts to address this before someone even posted it :-)

Coding standards are important when people have to work together,
where they have to read each others code,
and hope to help each other out with code or code review.

Where people work alone, and nobody else will even look at the code, ever,
coding standards don't matter a damm.

Maybe that applies to theme developers to some degree,
but if want your code to be part of the community, its better to have some standards so that people can work together.

If there were no PHP coding standards, core code would be a mess, a real mismatch of styles.

I'm going to go through all the comments soon, and finalise the standards.
Anything controversial will probably be left out, for now at least.

Thanks for the input though - any comments on the standards anyways?


Exactly

catch's picture
catch - Mon, 2008-09-15 21:26

I think it's pretty safe to say that if coding standards were dropped from core, then a big fraction of the development community would splinter, because it'd be nearly impossible to work out what was going on most of the time.


Standard Editor

smoothdzion's picture
smoothdzion - Mon, 2008-09-15 15:58

I agree with purrin. The more hoops people have to jump through to say "it's Drupal certified" the less jumping there will be. I think standards are good though when they make sense. I believe that there are common things we can do to make things organized better, but I don't think the spacing after styles, if elements/selectors are listed on a single line or not, are such a big issue. There is an exception for everything. I think the idea of common sense and organizing similar elements will create a very usable standard for most. I know with the tools I use I can easily find what I'm looking for without scrolling much at all.

I know that using Textmate it creates somewhat of a standard to how I code and it would take me more time to adjust things to look the way with 2 spaces to the left of every style then it would be worth. I think if you are going to create a standard then you better create a list of acceptable tools that can be used. It's the whole Internet Explorer and Firefox argument. If all tools were created the same and by default did the same exact things then we wouldn't be having this discussion because everyone would be using the same default formatting.

I use textmate to do everything and I'm sure other editors are used that don't do what Textmate can do. Maybe we should just start specifying what editors the stylesheets were created in so that people can understand what tools are being used. Then I would think that we would get a better understanding of what tools to standardize on if it ever came to that.

Brandon Buttars
Drupal Theme Development
http://www.odindev.com


...

sun.core's picture
sun.core - Mon, 2008-09-15 17:55

It's not about applications and your favorite tools. Please read Alan Burke's reply above; he explains the reasons why (coding) standards are important and healthy for a project like Drupal. No one cares which editor or whatever tool someone used to create or edit some bits of code, because almost all modern editors are able to apply a pre-defined coding style pattern to the source code.

Daniel F. Kudwien
unleashed mind


One property & one selector on one line

rhache's picture
rhache - Fri, 2008-11-28 01:06

I agree with Nick here. Any rule that has one property and one selector should be on one line.


Selectors and lines

Zarabadoo - Sun, 2008-08-31 19:48

I like putting my selectors on multiple lines. I can see why putting shorter length selectors on a single line would be convenient, I prefer to error on the side of consistency.

For me, it comes down to readability of the stylesheets. Drupal sites can be very complex beasts and the size of them can be quite large. Then you add the fact that in this community there will be several people looking at them and editing them, we will want to remove as much confusion as possible.


"While I see some

Morbus Iff's picture
Morbus Iff - Sun, 2008-08-31 22:15

"While I see some justification is being able to use both multiple selectors on one line, but use multiple lines if necessary, I'd rather be consistent." - than I'd vote for "multiple selectors on multiple lines". The dangers inherent in single-line usage is just too great.


While having two very short

brenda003's picture
brenda003 - Tue, 2008-09-02 02:26

While having two very short selectors on two lines can be annoying, if we're going for consistency I agree with Morbus here, otherwise there will be a lot of having have a VEEEERRY long line of incredibly long selectors. We all know those modules that give us way too many divs. ;)


+1 for: One selector per

Grugnog2's picture
Grugnog2 - Sun, 2008-08-31 22:50

+1 for:

  • One selector per line in all cases - less error prone
  • Standardizing on CSSDoc comment syntax, which is the closest thing to a standard that we have and it very friendly for folks who code almost any regular language

I am not sure about indentation of 'sub'-blocks as a whole as suggested by Zarabadoo (obviously the rules inside the braces should be indented 2 spaces). I can see how this could improve readability in some cases, but I would like to see a very very clear definition of when this indentation applies (i.e. one specific enough that we could write a coder rule for it).


Yeah I am not much of a fan

tjholowaychuk - Sun, 2008-08-31 22:58

Yeah I am not much of a fan of the whole visual nesting thing either, this is usually quite obvious from reading the selector. Plus nearly all stylesheets I have ever seen are not THAT unwieldy if structured in a relatively common sense method. A stronger CSS documentation syntax was widely accepted that would be great, IDE usage would be interesting as well. If you saw my Vision Media style sheet example above even just simple stylesheet explorers within our IDEs would be quite handy.

My CSSEdit module may be something worth looking at in the future as well, as it will implement these features, and provide real-time editing for Drupal themers.

Tj Holowaychuk

Vision Media - Victoria BC Web Design
Victoria British Columbia Web Design School


I didn't used to be much of

Zarabadoo - Sun, 2008-08-31 23:25

I didn't used to be much of a fan of it either until I started to use it. I normally use it within very defined areas that require the parent/child relationships. Proper and thorough commenting will be a much better focus before going too deep into this. I just wanted to give an example of things that have helped me on a whim that people would like it.


+1 for a single blank line

stella's picture
stella - Sun, 2008-08-31 23:19

+1 for a single blank line between rules
+1 for blocks of rules being "separated" or distinguished by comments just above them

As for multiple selectors on one line, not quite sure, which I prefer, but it's hard for Coder to support both methods :) So I'm probably leaning towards one per line,.... I dunno.... I keep changing my mind.

Morbus: can you outline some of the inherent dangers you see with single-line usage?

-1 for Zarabadoo's proposal on indenting blocks.

In the doc, you have an "Other" section in which you say "Header Comment Blocks, block level comments, filenames should follow the PHP coding standards." I would prefer if you actually specify what those are in the CSS standards doc. It would prevent users having to flip between docs. This is what I'm doing for the JS standards doc after receiving feedback from pwolanin and others today.

It might be an idea to specifically state what the indentation / spacing standard is, i.e. 2 spaces. I would like there to be a standard for one space after the colon. I think it is implied in the examples above, but I'm not sure you stated it.

Cheers,
Stella


Alphabetize, hex codes, and hyphens

stephthegeek's picture
stephthegeek - Mon, 2008-09-01 23:42

+1 for a single blank line between rules
+1 for blocks of rules being "separated" or distinguished by comments just above them

-1 for indenting (too hard to manage, better to use comments for related chunks)
-1 for multiple selectors per line -- I have been burned by this so many times, not seeing that there was another selector on the line as opposed to just a really long one

New standards proposals:
- Alphabetizing properties. It sounds kinda hokey at first, but after seeing it pop up in a couple of "best practices" lists, we started doing this a year or so ago and it's awesome.
- Color hex codes instead of names (#ffffff instead of white) -- for better scannability and accuracy
- Always using hyphens in class names, no underscores

~~~
{ Drupal Themes by TopNotchThemes } Gorgeous Drupal 5 & 6 designs with Views/Panels 2 support, plus Ubercart themes!


+1 to alphabetizing. This is

Zarabadoo - Tue, 2008-09-02 00:41

+1 to alphabetizing. This is another thing I use that is quite handy. Plus it is much easier to standardize on.
+1 to hex codes.

I am not sure with the hyphen thing. This will require cooperation with module developers also. I do prefer hyphens myself though.


+1 to hex (and full hex at

brenda003's picture
brenda003 - Tue, 2008-09-02 02:29

+1 to hex (and full hex at that)
+1 to hyphens

Could you explain alphabetizing properties?


+1 to hyphens on class/id

rhache's picture
rhache - Fri, 2008-11-28 01:08

+1 to hyphens on class/id


RGB

elv's picture
elv - Tue, 2008-09-02 08:14

What about RGB codes vs. hex?


+1 alphabetize properties

rhache's picture
rhache - Fri, 2008-11-28 01:11

One huge advantage is that your properties are in the same or order as Firebug.

-1 for indenting. baaaaaaaaaaaad idea. If CSS had script-like logic, I would agree.
+1 multiple selector each on one line.


+1 for alphabetizing

Morbus Iff's picture
Morbus Iff - Mon, 2008-09-01 23:59

+1 for alphabetizing properties. I've been doing that already on hook_menu and Form API arrays and, yep, definitely agree - it increases readability, scannability, and eases expectations. +1 for color hex codes, but then you go and say "#ffffff" instead of "#fff" (ideally, though, this is a "soft +1" from me - if you want the most accuracy, you'd use rgb(#, #, #), and I don't consider "#ff0" more "scannable" than say, "blue" or "red"; I only agree cos I practice "hex codes only" too). +1 for hyphens too. Another one I use everyday, and consistent with Drupal core's existing practices (i.e., there's no reason to argue against it, cos core's already doing it ;)).


-1 I [valley girl

Nick Lewis's picture
Nick Lewis - Tue, 2008-09-02 04:52

-1

I [valley girl voice]totally[/voice] disagree with alphabetizing. The importance of the rules needs to dictate where they go in the CSS document.

html > body > #content > #main-content > .node > .author

Don't hide body under .author because "A" becomes before "B"! CSS doesn't follow the alphabet. HTML "H" always comes before BODY "B".

++++++++++++++++++++++++++++++++
"I'm not concerned about all hell breaking loose, but that a PART of hell will break loose... it'll be much harder to detect." - George Carlin
++++++++++++++++++++++++++++++++
work: http://www.onnetworks.com
blog: http://www.nicklewis.org


Not to mention, the result

Nick Lewis's picture
Nick Lewis - Tue, 2008-09-02 05:17

Not to mention, the result might not be as good as we expect...

I think garlands style.css is worse alphabetized... attached is how it looks ( via this tool.... which does the java-style css thing by default... http://www.lonniebest.com/FormatCSS/ )

(Okay, so the thing spits out f#cked up CSS.... that isn't alphabetized, but instead follows #div > .class > element.... but really, this is a rule that makes people want to use the horrid tools... I don't want to encourage people to put code through these auto generators so it meets our standards....)

++++++++++++++++++++++++++++++++
"I'm not concerned about all hell breaking loose, but that a PART of hell will break loose... it'll be much harder to detect." - George Carlin
++++++++++++++++++++++++++++++++
work: http://www.onnetworks.com
blog: http://www.nicklewis.org

AttachmentSize
garland.txt 16.15 KB

I believe what was intended

Zarabadoo - Tue, 2008-09-02 06:13

I believe what was intended by alphabetizing is the individual style attributes on each set.

body {
  font-weight: normal;
  background: #000;
  font-family: helvetica, sans-serif;
  color: #fff;
}

vs

body {
  background: #000;
  color: #fff;
  font-family: helvetica, sans-serif;
  font-weight: normal;
}


Yep, that's what I was

stephthegeek's picture
stephthegeek - Tue, 2008-09-02 07:38

Yep, that's what I was referring to.

~~~
{ Drupal Themes from TopNotchThemes } Gorgeous Drupal 5 & 6 designs with Views/Panels 2 support, plus Ubercart themes!


Ah! :-D Who could argue

Nick Lewis's picture
Nick Lewis - Tue, 2008-09-02 18:12

Ah! :-D

Who could argue against that?
++++++++++++++++++++++++++++++++
"I'm not concerned about all hell breaking loose, but that a PART of hell will break loose... it'll be much harder to detect." - George Carlin
++++++++++++++++++++++++++++++++
work: http://www.onnetworks.com
blog: http://www.nicklewis.org


Awesome to hear this is being added to Coder (I heart Coder)

Jacine's picture
Jacine - Tue, 2008-09-02 05:15

Here's my 2 cents :)

+ 1 on hex
+ 1 on single line between rules
+ 1 for blocks of rules being "separated" or distinguished by comments just above them
+ 1 for Always using hyphens in class names, no underscores
+ 1 for alphabetizing properties. Does sound a little hokey, but I'll go with it :)
+ 1 for each link ending in a semicolon

- 1 on indentation
- 1 on multiple selectors on 1 line, for consistency sake, while it will surely be annoying in certain cases

+ 2 more...

1 - always use double quotes in HTML attributes, ie. <div class="class-name"> as opposed to <div class='class-name'> (though this is more regular coding standards, I had to say it)

2 - 1 space between property: & value, border: none; as opposed to border:none;

What about comments? What do you guys do? I've tried a few different ways in the past, but I find this works the best for me:

/*------------------------------------------------------------------------
 * MODULE SUPPORT
 *-----------------------------------------------------------------------*/

/* administration menu */
#admin-menu {
  font-size: .95em;
}

/* update status */
.versions table,
.versions td,
.versions th {
  border: none;
  overflow: auto;
}

I love comments delineating

Nick Lewis's picture
Nick Lewis - Tue, 2008-09-02 05:26
  1. I love comments delineating sections! I do this obsessively.
  2. Space between property and value seems to be a matter of taste. I personally always make a point of having no space... I see no compelling arguments either for or against the rule, so I think it should be left alone.
    ++++++++++++++++++++++++++++++++
    "I'm not concerned about all hell breaking loose, but that a PART of hell will break loose... it'll be much harder to detect." - George Carlin
    ++++++++++++++++++++++++++++++++
    work: http://www.onnetworks.com
    blog: http://www.nicklewis.org

Comments should always use

sun.core's picture
sun.core - Tue, 2008-09-02 13:37

Comments should always use CSSDoc syntax, just like we're using PHPDoc syntax for PHP. See http://cssdoc.net/wiki/DocBlock for an example. Personally, I hate those custom

/*** --- #### ##### Styles that apply to drunken output from here #### --- **/

that do not follow any reasonable syntax at all. Even more horrible:
/---------------- DO NOT CHANGE ANYTHING BELOW!!! ---------------*/

We all know them...

Aside from that, +1 for adding "Use double-quotes for HTML tag attributes." to our PHP coding standards.

Daniel F. Kudwien
unleashed mind


Very true. I find columns

tjholowaychuk - Tue, 2008-09-02 14:07

Very true. I find columns are more readable, but like you mentioned there really is no point to start a new syntax in that regards. When the time comes along that CSSDoc is a proper specification and IDEs embrace it then it wont matter if it is readable in plain text

Tj Holowaychuk

Vision Media - Victoria BC Web Design
Victoria British Columbia Web Design School


DocBlock

Jacine's picture
Jacine - Tue, 2008-09-02 14:37

It's great for PHP, CSS not so much... Section and Single Line Comments back to back are a real eye sore for me. If you could do single line comments, like you can in PHP, //, it wouldn't bother me. Just my opinion.


Inline comments

sun.core's picture
sun.core - Tue, 2008-09-02 15:02

Of course nothing should prevent you from using

/* Short inline comments. */

in addition to
/**
* Long CSSDoc block comments.
*
* Including additional information.
*
* @see andPointers
*/

Daniel F. Kudwien
unleashed mind


My point was that this is more geared toward PHP

Jacine's picture
Jacine - Tue, 2008-09-02 16:01

I hate this.... It looks like a jumbled up mess IMO.

/**
* Section
*/

/* Subsection */

Though when using it in PHP it doesn't bother me, but we are talking about CSS here so we can't use // (I'm well aware of this)

/**
* Section
*/

// Subsection

Anyway, whatever you guys decide is cool with me... I just wanted to express my hate for it publicly. I can still and will code my own way on non-contrib projects :)


I'm pretty sure // comments

stella's picture
stella - Tue, 2008-09-02 15:48

I'm pretty sure // comments aren't valid in CSS, and so you would have to use the /* .... */ method as described by sun.


Scroll-friendly comments delineating

donquixote - Wed, 2009-08-19 15:18

Yes, I like that!
Makes scrolling much easier.

Usually I use

/* ======================= SECTION ========= /

/
-------------------------- SUBSECTION ---------- */

I don't use ++++, that kills the "horizontal" look.


Definitely agree on your two

brenda003's picture
brenda003 - Tue, 2008-09-02 16:44

Definitely agree on your two later points. As for commenting, I use the more PHP way personally but I'm usually more of a developer these days. Those big comment lines always bugged me.

/**
* Section comment here
/

/
Minor comment here  */


Why standards?

alanburke - Tue, 2008-09-02 19:13

Good to see that consensus of some kind is emerging from the healthy discussion.
I've learned so many things, CSSdoc syntax, alphabetizing comments, indentation, etc.

It nice to step back briefly and ponder the reason for standards.
If the CSS works, then why should we care?

As I see it, coding standards are to allow developers to work closer together.
Having a common langauge means we can all contribute to the same project,
without the code becoming an ugly variant of styles.

I believe it's important that all code added to drupal.org, both core and contrib should follow the standards.
I realise that some people will heartily disagree with some of the standards, and try to rail against it in their own projects.

Please think again.

Every project can benefit from other people submitting code reviews, both manual and automatic, and from patches.
Where your code is outside the standards, you present a barrier, however small, to such co-operation.

As well as that, it may be that Coder module ratings could be used as a metric to rate projects [I certainly hope it will],
and your project would suffer.

Onwards with the discussion.

Alan


CSSDoc is not really much of

tjholowaychuk - Mon, 2008-09-22 14:29

CSSDoc is not really much of a standard yet, I wish though :) eventually !

Tj Holowaychuk

Vision Media - Victoria BC Web Design
Victoria British Columbia Web Design School


Updates.

alanburke - Tue, 2008-09-02 19:53

I have made the following updates.

Selectors are now one to a line.
Alphabetizing rule added.
Added rule specifying full hex values for colors.

I have addded a note on writing valid css, which needs review.
I have added a note on CSS comments, which needs review.

Indendation looks unlikey to get added, unless someone can come up with a very clear rule to define its use.

Some more questions.
Uppercase or lowercase?
I certainly prefer uppercase for hex values, but lowercase elsewhere.

Where should our HTML standards go?
Who wants to take that one on?
This is good start
http://groups.drupal.org/node/6355
but it needs to migrate to the handbook, and become a standard.

Alan


Lowercase

Zarabadoo - Tue, 2008-09-02 21:00

I prefer lowercase all around. A lot of that is because I don't like pressing the shift key if I don't have to and i really don't see having all caps on hex values of a lot of benefit since they are pretty identifiable on their own.


Lowercase yep. Still

Morbus Iff's picture
Morbus Iff - Tue, 2008-09-02 21:08

Lowercase yep. Still wondering why you're enforcing full hex colors (I note that you "responded" to it by invalidating my criticism, but not actually defining /WHY/ one should repeat #ffffff when #fff is just fine).


Hi Morbus, I'm enforcing

alanburke - Tue, 2008-09-02 21:27

Hi Morbus,
I'm enforcing nothing untill Stella gets her hands on whatever standard is final:-)

Again, I feel this just comes down to consistency.
Using the full 6 characters just seems consistent with other hex codes defined.

PS.
As someone who's entire code contribution conists of a Hex code [seriously],
I'm just trying to lead the way is agreeing a standard.

The documentation page is very much in flux right now.


Alan: I (now) agree that

Morbus Iff's picture
Morbus Iff - Tue, 2008-09-02 22:05

Alan:

  • I (now) agree that hex codes should be capitalized.
  • But, for the same reason, I again promote the 3-letter variants.

What changed one opinion but reinforced the other? The example in the CSS 2.1 standard, which uses "F00" (capital F, three-letter variant of FF0000). [EDIT: Actually, scratch that. They're not consistent themselves, as seen here.]


Ignore me, I think. I'll +1

Morbus Iff's picture
Morbus Iff - Tue, 2008-09-02 22:13

Ignore me, I think. I'll +1 capitalizing hex codes and +1 six-character only. Why the change of heart? Every graphic application I can find on my box always does capitals and six-characters, and I've just been changing them to my "house style" (3 and lowercase). So, I'll save myself an extra step in the future ;)


Keep your style, please. :)

sun.core's picture
sun.core - Wed, 2008-09-03 00:18

Like Zarabadoo, I don't like to press SHIFT so often. Also I find #E2A1C0 less readable than #e2a10, erm, sorry, misread that, #e2a1c0. That's because lowercase letters can be better distinguished from digits visually.
However, this is getting too nit-picky IMHO.

Re Hex: The purpose of coding standards is definitely not to limit features. #eee is a CSS feature, and I do not see a reason why we should not use it.

Daniel F. Kudwien
unleashed mind


The more I think about it,

Zarabadoo - Wed, 2008-09-03 06:12

The more I think about it, the less I like forcing hex. I don't really use the word colors unless I want a quick color so i can see the position of a block, but there is not real goo reason to eliminate them. RGB and HSL colors are becoming more useful also. Especially with Firefox3 adding support for RGBA and HSLA, I can see them being used much more as other browsers catch up.

So I recommend not restricting color declarations.


Must be something in the air..

alanburke - Tue, 2008-09-02 20:30

Mostly agree

laura s's picture
laura s - Wed, 2008-09-03 14:38
  • 1 on hex ... but I strongly believe short hex should be acceptable
  • 1 for blocks of rules being "separated" or distinguished by comments just above them
  • 1 for Always using hyphens in class names, no underscores
  • 1 for alphabetizing properties. Does sound a little hokey, but I'll go with it :)
  • 1 for each link ending in a semicolon
    +1 for always use double quotes in HTML attributes
    +1 for space between property: & value, border: none; as opposed to border:none;

0/0 (meh) on single line between rules. Okay, if that's a strong preference. It goes against the whole concept of chunking data for readability, but I can cope.

-1 on indentation (sorry Al -- works in xhtml, but confusing in css)
-1 on multiple selectors on 1 line, for consistency sake, while it will surely be annoying in certain cases
-1 on HEX CAPS. I say play it as it lays. If you're pasting from Colorzilla, it will have caps. If you're typing, it might not. I don't see a gain from imposing a rule on this

I would also add a fuzzier rule: Avoid adding specific IDs/classes from the detail end up. For example, a page ID and class can save a lot in specific IDs and classes on individual fields, lists, etc. Basic example:

<div id="happy" class="mood">
<p>When I am happy....</p>
<ul>
<li>I smile.</li>
<li>I have more energy.</li>
</ul>
</div>

is cleaner and preferable to:

<div class="container">
<p class="mood" id="happy">When I am happy....</p>
<ul>
<li class="mood">I smile.</li>
<li class="mood">I have more energy.</li>
</ul>
</div>

There's nothing like having to create a 5,000-line css to accommodate all the individual items that have been given overly detailed mark-up, especially when a simple, identified div container class and/or id are missing.

/rant

Laura
pingVision, LLC (we're hiring)


Totally agree with Laura's

ckng - Wed, 2008-09-03 15:08

Totally agree with Laura's points.
Colorzilla you can set it return lowercase hex (right click for option)

CK Ng | myFineJob.com

consultation • web design & development • content development • site domain, hosting & maintenance • software design & development


CSS

alanburke - Wed, 2008-09-03 18:52

Hi Laura,
The document is only concerned with the CSS coding standards,
but of course the HTML standards are closely linked.

The HTML markup and style guide mentioned above should evolve into some sort of a standard too,
but I'm going to wait till we're all done here before I tackle that.

Alan


As far as ordering of the

tjholowaychuk - Mon, 2008-09-08 23:12

As far as ordering of the rules I would somewhat agree with alphabetizing it, however I prefer to start with rules that are unlikely to change, then following with those that will. Also I prefer to utilize the box model as my ordering, so display, position, dimensions etc. example:

display: block;
position: absolute;
top: 0;
left: 0
margin: 0 0 0 0;
padding: 0 0 0 0;
width: 100px;
height: 100px;
font-size: 12px;
color: #fff;

Tj Holowaychuk

Vision Media - Victoria BC Web Design
Victoria British Columbia Web Design School


makes me think

mike stewart's picture
mike stewart - Tue, 2008-09-09 22:19

I thought alphabetizing was a good idea when I first read it. but after seeing @Tj Holowaychuk comment, i forgot how important grouping can be. I'm still undecided on this one.


Does the box model offer any

SteveJB's picture
SteveJB - Wed, 2008-09-10 06:14

Does the box model offer any performance (browser rendering) advantage?

I barely notice when properties are alphabetized and when they aren't.


Good question. I am sure

tjholowaychuk - Mon, 2008-09-15 18:42

Good question. I am sure implementations very but I would imagine the stylesheets are compiled before any rendering occurs so I would doubt this as any impact.

Tj Holowaychuk

Vision Media - Victoria BC Web Design
Victoria British Columbia Web Design School


Alphabetize properties is a huge -1

JohnAlbin's picture
JohnAlbin - Mon, 2008-09-15 17:24

I always use the box model method of ordering properties because it makes it easier to understand what the rule is actually doing. Many properties are interdependent and putting them next to each other makes that clear.

For example, let's put TJ's example in alphabetical order:

color: #fff;
display: block;
font-size: 12px;
height: 100px;
left: 0;
margin: 0;
padding: 0;
position: absolute;
top: 0;
width: 100px;

To me that is much harder to read. And if, for example, you start modifying the position, you are likely to forget to remove the top and left (or right and bottom which may or may not be in there too.) So alphabetical order makes it more likely you'll screw up the CSS when modifying it.

  - John (JohnAlbin)


box model

sun.core's picture
sun.core - Mon, 2008-09-15 18:10

I'm using this order, too. However, there is one caveat: All other properties that are not box-model-related can be added in arbitrary order. Also, there are certain properties like z-index that usually belong to another property, such as position: absolute, but do not belong to the box model. Additionally, rather important properties like display: block, display: inline, or overflow: hidden are not really tied to the box model - but should be noted at the beginning, because they have an great impact on the output. So, in the end we would have a rather complex standard on CSS property ordering - whereas an alphabetical order would be very simple, clean and easy to understand by everyone.

Please don't get me wrong, I'm also used to the "order by importance" as mentioned before, but I do not think we can get to a consensus about importance of CSS properties - besides the fact that the required work for defining and agreeing on the importance wouldn't be justified for CSS coding standards at all.

Daniel F. Kudwien
unleashed mind


I agree, its a tough call.

tjholowaychuk - Mon, 2008-09-15 18:40

I agree, its a tough call. Personally I find the 'boxmodel-ish' approach to be generally more logical as it is simply the order of which I would think when styling an element. First I need a block, then margins, padding, dimensions etc, I rarely would choose a font family before I specify the box. But again like you mentioned specific properties are not necessarily related

Tj Holowaychuk

Vision Media - Victoria BC Web Design
Victoria British Columbia Web Design School


Block vs. inline?

Crell's picture
Crell - Mon, 2008-09-15 20:55

What about just grouping that way? "Put all block-level rules first (margin, padding, position, etc.), followed by inline rules (color, font, letter spacing, etc.)" Would something at that level be a useful standard?


I think it makes pretty good

tjholowaychuk - Mon, 2008-09-22 14:33

I think it makes pretty good sense, personally I find when we start with block level declarations and then go on with fonts, backgrounds etc as long as they are grouped theres nothing really tough about reading it regardless of how its laid out. I just really hate when its fonts or colors first, I think about dimensions before any of that, and it sucks when its font-family, background, font-size, color, font-weight, all scrambled around.

Tj Holowaychuk

Vision Media - Victoria BC Web Design
Victoria British Columbia Web Design School


No grouping of properties

rhache's picture
rhache - Fri, 2008-11-28 01:21

-1 on that

Properties should be by alphabetized only (otherwise nothing). To start, it's not true that padding and margins are block level properties only. They apply to inline elements as well (but not for top/bottom). Second, very few properties are block or inline "only" really, and very few CSS coders really know the distinction.


completely disagree

rhache's picture
rhache - Fri, 2008-11-28 01:29

Not hard to read for me.

Initially I was very resistant to doing it alphabetically, but after forcing myself to try it for a short while it made more sense -- plus your code is in the same order as Firebug displays it. That to me is a massive advantage. Plus, I started seeing the code has a whole.

Second, alphabetical becomes automatic and you don't even have to think where a property goes. That can't be said of grouping properties, as I could come up with many scenarios where the grouping isn't obvious.

Lastly, Tj's example is a worst case scenario. Not completely uncommon, but exactly an every rule scenario.


http://cleancss.com/

smoothdzion's picture
smoothdzion - Mon, 2008-09-15 16:00

What if we everyone got into the common practice of using a site like http://cleancss.com/ to clean up all their css once it was all together. Would this make some people sleep better?

Brandon Buttars
Drupal Theme Development
http://www.odindev.com


CSSdoc is an alpha-level spec

JohnAlbin's picture
JohnAlbin - Mon, 2008-09-15 19:26

The CSSDoc spec needs a lot of work. And I don't think we should be adopting it prematurely.

I was asked to review it by the authors a few months back, but it was quickly apparent it wasn't worth my time. I have 2 major objections to it. One is there are no tools that actually build useful CSSDoc documentation. They list PHPDocumenter, etc, but those won't generate useful CSS documentation for the following reasons because they don't recognize the @rules that CSSdoc has created that differ from PHPdoc.

In other words, the proposed section comments (which don't even use the proper CSSdoc @section syntax) won't be recognized by the automated tools, or worse would apply the comment only to the first ruleset in the section.

And the proposal doesn't follow the full CSSdoc spec. The full CSSdoc spec would require full PHPdoc-block-like syntax for every comment you want to make. i.e. you would need one per css ruleset or per property. That's super code bloat. Inline comments are much better and they are way more compact.

The idea of @css-for, @bugfix, and @section are good, but requiring a full docblock for the @css-for and @bugfix is flawed given the amount of one-off property fixes needed for various browsers. (That's my second objection to CSSdoc.)

If we're not going to follow the full CSSdoc (and I don't think we should), there's no reason to do a half-way CSSdoc standard. That would lead to confusion (follow this part of the spec, but not that.) Now, an @file docblock does make sense, but that is identical to PHPDoc.

So what are we gaining by saying we are using CSSdoc syntax? Confusion over what parts apply to Drupal's standards and a shifting, alpha-level specification. :-\

  - John (JohnAlbin)


Great Feedback.

alanburke - Mon, 2008-09-15 20:59

Hi John,

Good to hear that input.
One of the reasons I proposed a standard is that the Zen styles vary from core a bit, and for some reason it kind of bugged me :-)

Given that the spec for CSSdoc is in flux, then perhaps we should avoid it for now?
What CSS documentation standard would you suggest?

As regards something to process the documentation, Neil Drumm is hoping to rewrite the code for api.drupal.org, and were appropriate coding standards in place, he could make use of that.

Regards
Alan

[I'm a bit tied up at the moment and am struggling to finish off the standards doc in any case]


We need something. Even

tjholowaychuk - Mon, 2008-09-22 14:36

We need something. Even simply outlining the document at the top of the file like an index, and then separating logical sections (forms, comments, tables, etc) is highly needed, and lower tolerance for one-liners. Also like you mentioned no IDEs even recognize or implement any form of CSSDoc syntax that I am aware of.

Tj Holowaychuk

Vision Media - Victoria BC Web Design
Victoria British Columbia Web Design School


Overall I like the standards

rhache's picture
rhache - Fri, 2008-11-28 02:03

Overall I like the standards and I'm sorry to not have participated in the discussion sooner. I have two major annoyances:

1- Not being able to leave CSS rules with one selector AND one property on one line
2- Having a blank line between between each and every rule

I could eventually learn to live with #2, but with much chagrin. #1, not giving it up.

Hopefully this will be revisited soon.


What is being achieved by all of this?

xtfer's picture
xtfer - Mon, 2009-07-27 09:58

I think its highly unlikely that I will suddenly change my CSS coding practices because of the Drupal coding standards. In contrast, I am more than happy to meet the PHP coding standards, as they actually make the PHP usable.

I always place CSS rules on a single line; ordered alphabetically; in ID, Class, then Element order. This helps me find items quickly, keeps the length short (less scrolling) and knocks out inheritance issues.

But aside from all that, formatting CSS is not important for readability in the same way it is in scripting languages. There are a lot of disagreements in this thread about what is readable and what isn't, which illustrates an important point with CSS: different strokes for different folks.

This problem stems from the fact that CSS can be organised in lots and lots of different ways, whereas a scripting language, for the most part, can not. Its procedural elements MUST be in order. Because of Specificity, CSS can theoretically be in ANY order.

Perhaps we should be focussing on usage standards, not formatting... things like

  • lowercase selectors
  • hex standards
  • use of comments
  • splitting layout & design

I agree with this. I HAVE

theresaanna's picture
theresaanna - Mon, 2009-07-27 15:13

I agree with this.

I HAVE altered my methods in working on professional and contrib themes, but to me readable is single line declarations, attributes in order of importance (which is totally subjective to the coder).

I can definitely get on board with some guidelines, but as xtfer said, much of what we are discussing here is preference. What is readable to me, what makes sense to me might not be ideal for you. This is not to say that I don't think the community shouldn't adopt guidelines and specifications as they are completed and accepted by the developer community as a whole. I just don't personally feel that it will be particularly advantageous for the Drupal community to iron out each detail.

Has a situation arisen that has led us to seek a standard as a solution? My view is, at this stage, the priority is getting more high quality, standards compliant themes into Drupal. If this would fix an ongoing issue that is a different matter.


Topic is not custom code

sun.core's picture
sun.core - Mon, 2009-07-27 17:14

The topic and focus is not custom code. We are talking about coding standards for Drupal core and thereby also contributed modules. Setting up a CSS coding standard will make the code readable for all, and at the same time, answer all of the current questions that arise for contributors these days:

In which way should I write CSS? Just follow what's there in the same file or should I follow CSSDoc standards? And why are selectors written differently over here? ... but user XYZ told me, I should write it this way!!

Not having clear instructions on how to write CSS code hinders development.

Daniel F. Kudwien
unleashed mind


Don't give me none of that SASS

deeporange1's picture
deeporange1 - Mon, 2009-07-27 17:46

Actually SASS looks pretty cool: http://sass-lang.com/ ... Anyone used it? I am thinking of giving it a go sometime. How would SASS fit in with this discussion? SASS is an alternative method for coding CSS so that you can have neat things like variables and (actual) nesting of selectors.

I am thinking that SASS would really fly in the face of CSSDoc though (from what I can tell). I suppose it really depends on what the SASS interpreter's output looks like though. As I recall it looks fairly different from vanilla CSS in terms of indentation, spacing, etc... It may alphabetize. But a tool like this could change the way we code CSS as well.

Derek