Building a CSS Framework Part I: Organization

Introduction

I recently attended An Event Apart Boston in June. Among the many talented speakers was Eric Meyer. The CSS Guru gave a very informative presentation on CSS frameworks and one of the first things he suggested doing was creating your own. His research provided information such as commonly used font sizes for headings, naming conventions and layouts. I was relieved knowing that I had already spent some time building my own and that it was in accordance to Eric’s suggestion.
Before I get into the inner workings of my framework I would like to discuss a few organizational points. One of the things that I’ve found to be very useful is dividing my CSS into 3 separate areas.

  1. main.css - layout aspects such as height, width, padding, margins, etc…
  2. type.css - typography aspects including line-height, font sizes, text transformations & letter spacing.
  3. color.css - background images and colors, borders, text decorations & list styles

From this point I link to ‘main.css’ and ‘@import’ the other 2 along with a browser reset style sheet which I will discuss later. This is only personal preference as I find easier to find and manage specific areas of my code. Keep in mind, however, that IE6 will not cache the imported style sheets and will reload them with each page load. Also remember when importing that your @import must be the first rules in your ‘main.css’ style sheet.
My CSS Framework began with me pulling code snippets from various resources and gradually layering in things such as header sizes and various layout schemes. It is an ever growing child and like some children it can grow up to be very, very ugly. In other words, it has the potential to get extremely bloated and messing. I myself appreciate the light-weight frameworks such as jQuery and endeavor to keep this as light-weight as possible.

Tracking Your Styles

Whether you work alone or as part of a team, using comments in your code can be very helpful in maintaining your code and ultimately your websites. Each style sheet contains relevant information commented conveniently at the top. Here is a look at ‘main.css’.
/*------------------------------------------------------------------
[Master Stylesheet]
Project:
Version:
Last change:
——————————————————————-*/

You can add any relevant data that suites your specific work-flow. As of this posting I have not discovered a need for any sort of commented guidelines for ‘type.css’. Moving on. Let’s look at ‘color.css’ which contains a color glossary.

/*------------------------------------------------------------------
[Color Glossary]
Mid Gray (background) #808080
Dark Gray (text) #1E1E1E
Light Blue (headings) #99FFFF
Yellow (header) #FFFF33
Dark Purple (navigation) #660099
Aqua Blue (links) #00FFFF
——————————————————————*/

This is one of the most useful tools in your framework. It helps to keep a consistent color scheme and you never have to go scramble to figure out what the hex value to use.
Going back to ‘main.css’ directly after the commented data I want to import ‘reset.css’ followed by ‘type.css’ and ‘color.css’.

@import url('reset.css');
@import url('color.css');
@import url('type.css');

Now our CSS Framework has a solid foundation for building additional rules. You can organize your style sheets anyway that suites you or your teams work-flow. I hope you enjoyed this epic post and will return to read the upcoming and exciting sequels.

A List Apart: The Survey For People Who Make Websites

I just completed the A List Apart Web Design Survey. It took all of 10 minutes to complete and did not require much thought. I’m confident that the information that the survey provides will give me and other web professionals a good view of where we stand in our careers. If you are a web professional I strongly encourage you to contribute and take this survey. We will all benefit from this priceless knowledge.

Introducing CSS Meltdown

Deep within the molten core of a corporate hell, from the burning embers of marketing, emerges a demonic force driven by a devotion to web standards.

OK. OK. So its not actually demonic. I just thought it would be cool to introduce CSS Meltdown as a force to be reckoned with. Within the pages of CSS Meltdown you will find articles dealing with web standards in a corporate environment, CSS techniques and guidelines, business ethics in the web industry, latest news and links to some of my most influential resources.

The goal of CSS Meltdown is… well there is no real set goal. Only a single purpose; to provide an honest opinion of the current path of the web and provide solutions and guidelines to correct its course. I hope everyone who reads these posts will either come away with a better understanding of the concepts that I have inherited or devised over the past couple of years or have contributed to these concepts by stating their honest opinions. Whether those opinions be objective or in concurrence with these ideas is irrelevant. Only that they are constructive and nurture the young child that is the internet.

I would like to thank Wordpress for creating such a wonderful and useful product. I would also like to thank Andy Clarke, Eric Meyer and Jeffery Zeldman for all their influence and hard work that has made the web a better experience for everyone. Last but certainly not least, I would like to thank one of my instructors at Full Sail University, Mike Girouard and classmate Micheal Parler for coaching me through the early stages in my career.