CSS Structuring
This 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…






Pingbacks and Trackbacks
This is the TrackBack URI for this post.
There are currently 0 pingbacks/trackbacks (Show)2 Comments
I follow a similar method, and have found alphabetizing to actually have some negative effects by not following the DOM very well, you can inadvertently over-ride a particular style. These might be easier to read, but certainly harder to debug.
Yeah, exactly my point. I always keep in mind the debugging phase, and my goal is to minimize that time as much as possible. Hence, making code easier to debug is a priority.
Leave a comment