CSS Structuring
Tuesday, October 24th, 2006This post from Khaled made me think about the way I write my CSS, have always written my CSS code. I follow the regular one element, one line approach for attributes with more than 2 elements, and a single line for 2 or lesser. I’ve found that the spacing helps me easily sort through files, and find some rogue piece of code.
However, structuring doesn’t end there. There is also positioning elements, comments, and such.
I usually start the file with a little comment, and don’t usually comment, unless some bugs are encountered, and obviously for the Holly Hack. ![]()
As for positioning, I’ve noticed people mostly alphabetize their CSS attributes, but I never found it comfortable finding a letter and placing codes…
I go from top to bottom. I mean, I follow the XHTML coding. I go from the first id or class encountered, to the last. I don’t even differentiate between ids or classes. I find having relative CSS codes next to each other a big help when it comes to debugging.
So, am I doing something anti-productive? What do you follow? I wanna know…