Of course, there isn’t a right way to write CSS. It’s all down to preference.
Now this isn’t anything life changing or revolutionary so don’t get all upset once finished.
It wasn’t until 2006 when I learnt of stylesheets. All I knew of was .style1 and .style2 at the top of every page that I’d spend hours changing.
And since then, how I write CSS has changed from the “all over the fucking show” to the “all over the fucking show but a bit more structured” approach.
I’ve tried the all on one line and the rules on each list, sometimes in importance order and sometimes alphabetical. I’ve tried SASS and LESS also
I’ve recently started a new job, and with it came a set of guidelines for when writing CSS and various other stuff. I still haven’t mastered it as I often slip into lazy Dan mode but it’s getting there.
I’ve this weekend started work on a personal project and have started a new way that was introduced to me by Rachel Shillcock aka @missrachilli (She didn’t invent it before people start kicking off). The idea is that you have the first rule and anything associated with that gets indented. I believe SASS/LESS do the same. I guess it helps to find things easier. And it does, well certainly feels like it. The CSS feels organised and easier to navigate.
{edit} I’ve created this little jsfiddle to show what I mean http://jsfiddle.net/danjdavies/4RK9W/{/edit}
I’ve read so much in the past about CSS layout and it confused me to the point where I was scared to ask. Now, well as I said, there isn’t a wrong way but there is a tidy way and this feels right
As I said earlier, nothing new and life changing, just putting it out there