November 29, 201213 yr I've recently started gearing my code more towards SMACSS and OOCSS but in doing so it's opened up a can of worms. I've had all kinds of ideas on how best to structure CSS and CSS related HTML. For example I've started using a lot more classes to isolate different elements for a) potential reuse and b.) avoidance of potential clashes with other elements, e.g. using one class for many elements is eventually going to force you to overwrite that class whereas having specific classes means you give each element its' own styling. I'm currently thinking about devoting a section of my CSS purely to any structural element that could potentially be reused. So instead of a promotion box layout and styling going under a page section it would simply go under something like /* Promo box A */ so that the tags could simply be reused not only across a specific site but any site in the future. Anyway to my point, I wondered if anyone else was thinking along these lines or if anyone has any other interesting/useful ways to structure CSS? Edited November 29, 201213 yr by jtuds
November 30, 201213 yr I adore SMACSS, it changed the way I write CSS more-or-less overnight. So welcome to the winning team In terms of ordering, there's no shame in creating structural classes and using them in several places on your page. I tend to find that I don't need many though, I usually have one for floated elements with a container that wraps them, absolutely positioned children in a relatively positioned parent and lists without bullets. I find that they solve most of my woes and anything more unique (such as a set width) becomes it's own module. I also tend to create my CSS gradients as a module to handle some of the intricacies, and CSS animations are a module to get as much browser support as possible. I have a base style sheet that I use whenever I start, you're welcome to take a look. It's on my Gist. I hope that helps answer your question
November 30, 201213 yr I began using SASS only yesterday. That is definatley going to speed my up, I have wanted to be able to use variables in CSS for a long while now.
Create an account or sign in to comment