@Michael: I don’t know about you, but I’m smart enough to be able to take what is written here and run with it; not everything needs to be a how-to manual. Sometimes even a little bit of (gasp) theory goes a long way.
This actually is very timely for me. During my recent performance evaluation, my manager said I needed to get better about “recycling code”. I told him to go jump in a lake, that what I do doesn’t lend itself very well to recycling. After all, it’s not like I’m writing functions…But now I’m rethinking. In fact, I’m excited about putting the main idea into action. I’m curious to see how the rest of my team likes it as well.
The title of the article reminded me of “Templation”:http://templation.websaviour.com/. The HTML/CSS templating system I developed several years ago to solve the problem of managing a site with hundreds of HTML pages mixed with a variety of PHP applications. It really is a “framework for designers” in the sense that it is primarily concerned with managing HTML and doesn’t throw a lot of cruft your way.
These days everyone wants a content management system, but if you ever work on sites with static content, or that integrate several different PHP apps, Templation is a very slick way to DRY out your HTML. If your CSS framework contains some boilerplate HTML you can set this all up as a generic template that is accessible to all sites on your server, but can be overriden on a per-site or per-directory basis.
The web development community as a whole used to be as cohesive and civil as the css community—then frameworks reared their ugly heads, and now you’re either rails or django, prototype or yahoo, tomato or tomaaahto, and never the twain shall meet.
Web development is now a house divided, and with your article, the quiet little corner of CSS will soon follow down that sad, misguided path—-You can see it in the comments already!
Please, for the love of all that is holy, REMOVETHISARTICLE!
Didn’t see this mentioned in any of the comments after a quick scan, but Rails 2.0 (or whatever it will be called) will have baked in functionality to take a set of CSS files and essentially concatenate them into a single file to save on HTTP connections.
The basic syntax is something like:
stylesheet_link_tag :all, :cache => true
which will take all your CSS files and send them to the browser as a single file named all.css.
Copy & paste the code below to embed this comment.
John Bertucci
First, thanks for the article on frameworks. It was good to read as I have been seeing this word tossed around quite a bit lately but I didn’t really grasp the the specifics of it.
As it turns out, I guess I’ve been using “CSS Frameworks” for myself for a while, without directly knowing it. Overtime this process just evolved into a framework. However, after reading the book “Transcending CSS” by Andy Clarke (edited by Molly e. Holzschlag and a preface by Dave Shea), I used the recommendation to setup 5 CSS files.
layout = the ‘reset’ code, template and page specific layouts (margins, paddings, widths, heights, positions, displays, etc)
type = font size, type, decoration, etc
color = font colors, background colors/images, etc
ie-fixes = a style sheet that’s included only with IE (via conditional comments)
master = this calls all other style sheets (except IE which is called via conditional comments to only be included in IE browsers)
Though, as you pointed out in the end of your article, I do worry that this number of HTTP connections can start to get absurd. What I wanted to do is also extract the “reset” code into it’s own style sheet, and after reading your article, I’d love to set aside code for a “horizontal list menu” that I find myself using ALL the time. Do so, would mean I wouldn’t have to go back and open out old CSS files to find the code I used and how I used it (though, I’ve used it enough it doesn’t take very long, but there’s also Javascript code that goes with it, which came from an ALA article!)
Usually, my thoughts turn to “caching”. So what if I have to open up 5-6 HTTP connections just for CSS files? Isn’t the point of CSS files the ability for browsers to cache said file and avoid an HTTP connection all together? Along the lines of images? Maybe my networking knowledge is light, but does this not make sense? Are there still HTTP connections opened to check file dates and if file refreshes are required?
I would also appreciate more general ‘intro’ articles about frameworks in general. Frameworks on the server-side (Ruby, PHP, JSP, ASP, etc). What are some good ones? What are the general designs behind them? Are there any good books?
Thanks for the long, thoughtful comment. The sort of framework I’m writing about in this piece is reused. That is to say, you would use the exact same stylesheets from project to project. I’m not sure if you’re doing this or not, but you inclusion of a “layout” sheet made me wonder. You say it includes page-specific elements, which leads me to wonder if it’s actually reused from site to site (or even page to page). Same with “color”—this isn’t likely to be the same from site to site, is it? If it is, then by all means, abstract it and reuse it! But, at least for me, it’s rare that the layout and color are the same from site to site.
There is some browser-level caching of stylesheets, but that doesn’t change the fact that five stylesheets equals more HTTP connections than one. :)
As for server-side frameworks, everyone knows I have an affinity for Django.
Copy & paste the code below to embed this comment.
Angel Colberg
You hit on a lot of good points and it is a great starting place for anyone wanting to create their own specific framework depending on specific user requirements they might have. I know personally that by using a framework based approach I have been able to cover all of my bases in order to create a comprehensive user experience without having to do too much redundant thinking and getting right to work on particulars. Lately I’ve been using WYMstyle – It is pretty huge, but I grab what I need depending on my project thereby standardizing various aspects of my workflow. Like I said, it is huge, but definitely well worth looking at.
Peace.
Copy & paste the code below to embed this comment.
Tim Finley
I’ve worked with a few designers in a similar “framework” manner recently, though I think we may have pushed things too far. We didn’t only share the overall layout and branding for a few sites, we also shared the same “widget” styling (think page navigation, header, footer, list of user names, form layout, etc).
Some times that would work really well since the hard cross-browser work of one person was applied to many pages, but things got very hairy when you nested these CSS widgets inside one another (especially when you added your own page specific tweaks here and there). The problem was that we couldn’t use the ‘>’ operator to select a child element (stupid IE) and had to make rules too general.
We were trying to make clean CSS selectors with as few class names as possible (think ul.tagcloud li a), but when you nest rules like that you get all kinds of crazy overlap from overly generic element selectors.
I still think that our effort was useful, but consistent CSS implementations would make this much easier.
Given that the article leads off by saluting the (fantastic) YUI along with other front-end engineering frameworks, I’d like to direct your readers’ attention to the Yahoo Design Pattern Library (http://developer.yahoo.com/ypatterns/). The YUI and YPL are closely related and we are working on making them even more useful for designers, developers, and hybrids.
This is a great article, and very relevant to what I’m working on right now. It seems like I learn something new after every new site produced to come closer to the subject of this article, but I don’t have the luxury of working on a mega-site like Yahoo yet to cooperate with frameworks that really make a difference.
What I do know is that this pursuit makes production much easier to keep things simple, clean and as standardized as possible so engineering can program exactly what we intended. However, the designs I produce tend to be so pixel-precise and intricate with multiple font decorations per line and slight alterations designers love to include. My pursuit of standards and frameworks break down by the time we launch because of all the little page-level tweaks to keep things pixel-perfect. Do sites that focus on less highly-designed Web content have less trouble adhering to standards and frameworks?
Copy & paste the code below to embed this comment.
Brian Blanton
I really enjoy the articles on this site, and am still amazed how the internet can give you access to so many cool people. I live in Charlotte, NC and am having trouble hooking up with other people to discuss this stuff.
Anyway, one thing I started doing is using the code completion in my text editor to write my standard css files for me. Think of custom textmate bundles for writing certain parts of your css file. (I’m on windows at the moment, so I use http://www.e-texteditor.com/, but it works the same more or less).
So if you are going to use left navigation, maybe you create a shortcut named xxleftnav or xxrightnav for right navigation and so forth. If you’re like me when you work on new sites you tend to have the same layout structures which lend themselves to a library of css layout templates. Enjoy, Brian
Great article, I think it would be a good idea for me to make a CSS framework.
You rightly mention that multiple stylesheets can have a significant impact on performance, and that one stylesheet it a solution, but say this is inconvenient to update. I don’t think it would be as bad as you make it out to be, and in my opinion this would be best if the stylesheet was well commented.
Hey Alex, thanks for your comments! I think it’s simply personal prefer as to whether people like maintaining one long CSS file or a handful of shorter ones. I like breaking them out, but I definitely know people who like one long one better. So, to each his own.
The other downside of one long file, though—besides maintenance—is that you can’t include only bits of the framework, you always have to include the whole thing. Depending on the framework you create, this may or may not be an issue, but it’s something to think about.
I think the ideal solution is to allow for multiple files but have a server-side process that concatenates them together and sends only one long file to the browser.
Hey all,
After reading Jeff’s article, I put together a simple framework using paradigms I’ve found helpful in most of my projects (I’d been thinking about it for a while, but the article convinced me to bite the bullet).
I’m releasing it under GNU in hopes it might be useful to others too. I’m calling it Taffy (Every framework needs a cute name, right?). Hope it helps out, if not as a framework, at least as another example.
Check it out here: “Taffy Framework”:http://www.gordonbrander.com/taffy-framework
I’m not a web designer, just some idiot who has time to much around with her own site. But, this is something I was looking for two years ago when people started talking about CSS and XHTML and having sites that were accessible. I’m glad to see someone thinking about it who actually knows what they are doing. I’d love to have a frame. Especially right now as I have still not fixed my code, mainly because I’ve had less time and less patience and after all it is just my pet project. Hardly anyone but me knows about it. :)
Copy & paste the code below to embed this comment.
Armand rousso
I have seen many design teams using framework and specially offshore team, in order to keep them not to far from what was required we suggest framework. Armand Rousso
A clean usable set of code to do header, menu, 2 and 3 col body, and footer available in a forum is doable. Someone who has asked needs to take and volunteer to moderate it and we can tean to create content. 1ho volunteers? ((-:
5ale on my blkbry in Oceans 13
If you create a frameworks of multiple CSS files and concatenate them in one long file, server-side, you are saving the HTTP requests and lightening the load on your server; but you are creating a scenario where you are potentially creating many different on-the-fly, unique css files that are long and different page by page. In other words, the client must download them each time because they will not be recognized as cached (even though they are using the same chunks of frameworks). On top of that, for every unique sheet that’s not seen as being cached, the client will download all those bits and bytes again—more tax on your server.
If you use the individual framework components as separate files, you are taking advantage of caching in the client, but then you are creating a server load as the clients tax the server with HTTP requests to see if their cached versions have been updated on the server or not.
Seems like the server-side solution could be a good one as long as you limit the number of permutations of unique files that the server-side solution would serve up.
While this is a great article, it could use more examples. I really hate to see the multiple http request problem not solved. I would just create in PHP (or your language of choice) one file that includes all the others (e.g. using php’s include function) – at least that will reduce the network overhead.
In the past I have merely copied, pasted and modified working CSS from past sites when designing new ones with a similar layout, so moving to a framework is a logical step. Thanks for bringing Yahoo’s UI library to my attention, too – it looks incredibly useful. I look forward to cutting out time working out issues like why my div is 2 pixels to the left in IE and having fun getting back to actually designing!
If you use “TextMate”:http://macromates.com/ , you can specify the default content when creating new files types. For example, you can edit the template that creates new XHTML Strict 1.0 documents to already have the structure you prefer (like including YUICSS links, etc…).
I then use “Snipplr”:http://snipplr.com/ and their “TextMate Bundle”:http://snipplr.com/extras/textmate/ to easily pull in my own code snippets or favorite code snippets. The bundle saves those snippets offline in TextMate, which is useful if I’m coding offline. The combination of TextMate and Snipplr is my framework.
Good article, this is something that I’ve been thinking about quite a bit recently. Most of it seems like common sense, but then all the best ideas do. I agree with Jon Henshaw above with regard to ‘implementing’ this framework.
I have a few core CSS files that I always start a site with:
reset.css (from Eric Meyer)
IE_only.css (to sort out the misbehaving children)
styles.css.
The last one will eventually have all the main styles in, but it starts with some basics that I always use (styles for links, setting font size to 62.5% etc) and then I build on this.
Any common code that I often use is saved as snippets for use with the Scribes text editor. For example I have a nice snippet that creates a tabbed navigation bar within a few keystrokes – it makes development much quicker.
Site-wide blocks like sidebars, navigations and complex forms included after the content section. My ideal positions of the code blocks in the <body> are as follows:
1. Header — contains logo (image) and concise slogan (text) of the site. Header can also contain few links to the most important navigation sections of the site (2-5 links) and breadcrumb trails. It is important to keep this information first for branding and accessibility. This also tells the search engine which pages are the most important.
2. Content — starts with heading 1 and continue with the copy paragraph text, headings (2, 3”¦), unordered and ordered lists”¦ If the content contains semantic blocks, these should be wrapped in a div. Example: information about one product in a group of products should be enclosed in a <div>. This <div> can contain heading with the link to the product page, image of the product and paragraph text with the product description. More information about the content and copywriting has been in the copywriting guidelines document.
3. Secondary content — if you have one, it is usually the non-site-wide navigation specific for the current section
4. Sidebars — should contain site-wide-navigation and all the site—wide search forms and similar stuff. The ideal structure of the navigation is unordered list <ul><li>”¦</li></ul> or nested unordered list <ul><li>Section<ul><li>Subsections</li><li>another subsection</li></ul></li></ul> in case you have sub sections. If the sections contain many other sub-sections, you should put this in a separate list to the secondary content. See ““http://css.maxdesign.com.au/listamatic/”:http://css.maxdesign.com.au/listamatic/ to find out how to give your list-based navigation the look you need.
5. Footer — contains the most generic information. Footer may contain information about author/owner of the page enclosed in the <address> tag. The <address> should contain full address, e-mail and telephone number. You may want to add more semantics here using VCARD format. To include an address is espacially important for local business sites to make the page rank for local terms: “Type of the business and name of the location”? (E.g.: Travel agents Swindon, PPC Warrington) and ensure user can easily find contact details. Footer can also contain link to T&C, Site-wide sitemap and copyright/licence information.
6. Wrapper – Everything is wrapped in the wrapper to make it easier to create which has its position:relative to make the layouts easier with position:absolute
Copy & paste the code below to embed this comment.
Mulyadi Oey
This is a good article. Thank you.
My main concern is that how are we going to communicate the existing styles to the other designers for reuse? More often than not, the styles do not get reused simply because they are hard to find. Should we create some sorts of documentations (e.g. screenshots) for every major style?
This is a great article to get us thinking. I really like the idea of standardizing our approach to CSS.
To your list of 5 basic style sheets I might add one for microformats since there are some basic styles I generally end up applying to them and the classes are 100% predictable.
I worry that class names like “tabs” aren’t semantic. I haven’t played around with it myself (I have a full time day job maintaining one site) but I’m wondering what your thoughts are on starting with a predictable basic XHTML layout that has common semantic class/id names in it like a header area with a nav list in it by default and then grabbing an applying different basic style sheets (or parts of sheets) depending on how you want those formatted.
Copy & paste the code below to embed this comment.
LeMel LeMel
On HTTP connections vs. stylesheet size, what’s wrong with using @import in a CSS 2.0 world? Cascading is supposed to be a core feature—it’s the ‘C’ in CSS after all.
For the framework I built for our developers, there is a basic.css. More advanced stylesheets import the BASIC.css. Some have multiple imports to other css ‘modules’, for example, TOOL.css imports BASIC and GRID (GRID imports TABLE), while GUIDE.css which doesn’t need GRID only imports BASIC and TABLE.
As long as you keep the functionalities simple and nested, developers only see a few choices (TOOL, GUIDE), and the cascade logic takes care of the rest, while giving me the ability to add new modules or styles only where needed without steadily increasing BASIC.
I’m sure some more advanced folks will let me know why this is bad somehow, but it has worked here for a few years in our (admittedly homogenous) environment (an intranet).
As many others, I really like to keep it minimal. But even at minimal, I tend to use at least three CSS files. Basics, IE fixes and then the rest. I’ve never used a framework and probably never will. Good article tough, many points i’ve not know of. Thanks!
I know it’s been a while since you’ve written this article, but I wanted to tell you thanks for taking the time to share your experience. We have been getting a lot of requests for larger MVC sites that are very complex from a GUI perspective (not to mention the programming aspect), and we are definitely seeking an optimal approach with our CSS and designs, as we’ve been spending a lot of time looking at each other’s CSS and going, “huh?” and “what the …”.
You said:
Have a server-side process that dynamically flattens the individual files into a single response. I’ve not seen this done, but it could be very efficient if done well.
Actually Google Pagespeed project supplies code that can be used to flatten and minify your css into a single request.
55 Reader Comments
Back to the ArticleJeff Croft
Just wanted to say thanks to everyone—glad you’re liking the piece! Keep up the great discussion. :)
Jiri Vanmeerbeeck
such as “YAML”:http://www.yaml.de/index.html ?
amber simmons
@Michael: I don’t know about you, but I’m smart enough to be able to take what is written here and run with it; not everything needs to be a how-to manual. Sometimes even a little bit of (gasp) theory goes a long way.
This actually is very timely for me. During my recent performance evaluation, my manager said I needed to get better about “recycling code”. I told him to go jump in a lake, that what I do doesn’t lend itself very well to recycling. After all, it’s not like I’m writing functions…But now I’m rethinking. In fact, I’m excited about putting the main idea into action. I’m curious to see how the rest of my team likes it as well.
Gabe da Silveira
The title of the article reminded me of “Templation”:http://templation.websaviour.com/. The HTML/CSS templating system I developed several years ago to solve the problem of managing a site with hundreds of HTML pages mixed with a variety of PHP applications. It really is a “framework for designers” in the sense that it is primarily concerned with managing HTML and doesn’t throw a lot of cruft your way.
These days everyone wants a content management system, but if you ever work on sites with static content, or that integrate several different PHP apps, Templation is a very slick way to DRY out your HTML. If your CSS framework contains some boilerplate HTML you can set this all up as a generic template that is accessible to all sites on your server, but can be overriden on a per-site or per-directory basis.
Dave Cooper
Ack!
The web development community as a whole used to be as cohesive and civil as the css community—then frameworks reared their ugly heads, and now you’re either rails or django, prototype or yahoo, tomato or tomaaahto, and never the twain shall meet.
Web development is now a house divided, and with your article, the quiet little corner of CSS will soon follow down that sad, misguided path—-You can see it in the comments already!
Please, for the love of all that is holy, REMOVE THIS ARTICLE!
/* actually, don’t…it’s a great idea */
Scott Boms
Didn’t see this mentioned in any of the comments after a quick scan, but Rails 2.0 (or whatever it will be called) will have baked in functionality to take a set of CSS files and essentially concatenate them into a single file to save on HTTP connections.
The basic syntax is something like:
stylesheet_link_tag :all, :cache => true
which will take all your CSS files and send them to the browser as a single file named all.css.
John Bertucci
First, thanks for the article on frameworks. It was good to read as I have been seeing this word tossed around quite a bit lately but I didn’t really grasp the the specifics of it.
As it turns out, I guess I’ve been using “CSS Frameworks” for myself for a while, without directly knowing it. Overtime this process just evolved into a framework. However, after reading the book “Transcending CSS” by Andy Clarke (edited by Molly e. Holzschlag and a preface by Dave Shea), I used the recommendation to setup 5 CSS files.
Though, as you pointed out in the end of your article, I do worry that this number of HTTP connections can start to get absurd. What I wanted to do is also extract the “reset” code into it’s own style sheet, and after reading your article, I’d love to set aside code for a “horizontal list menu” that I find myself using ALL the time. Do so, would mean I wouldn’t have to go back and open out old CSS files to find the code I used and how I used it (though, I’ve used it enough it doesn’t take very long, but there’s also Javascript code that goes with it, which came from an ALA article!)
Usually, my thoughts turn to “caching”. So what if I have to open up 5-6 HTTP connections just for CSS files? Isn’t the point of CSS files the ability for browsers to cache said file and avoid an HTTP connection all together? Along the lines of images? Maybe my networking knowledge is light, but does this not make sense? Are there still HTTP connections opened to check file dates and if file refreshes are required?
I would also appreciate more general ‘intro’ articles about frameworks in general. Frameworks on the server-side (Ruby, PHP, JSP, ASP, etc). What are some good ones? What are the general designs behind them? Are there any good books?
Cheers,
Joh
Jeff Croft
John-
Thanks for the long, thoughtful comment. The sort of framework I’m writing about in this piece is reused. That is to say, you would use the exact same stylesheets from project to project. I’m not sure if you’re doing this or not, but you inclusion of a “layout” sheet made me wonder. You say it includes page-specific elements, which leads me to wonder if it’s actually reused from site to site (or even page to page). Same with “color”—this isn’t likely to be the same from site to site, is it? If it is, then by all means, abstract it and reuse it! But, at least for me, it’s rare that the layout and color are the same from site to site.
There is some browser-level caching of stylesheets, but that doesn’t change the fact that five stylesheets equals more HTTP connections than one. :)
As for server-side frameworks, everyone knows I have an affinity for Django.
Angel Colberg
You hit on a lot of good points and it is a great starting place for anyone wanting to create their own specific framework depending on specific user requirements they might have. I know personally that by using a framework based approach I have been able to cover all of my bases in order to create a comprehensive user experience without having to do too much redundant thinking and getting right to work on particulars. Lately I’ve been using WYMstyle – It is pretty huge, but I grab what I need depending on my project thereby standardizing various aspects of my workflow. Like I said, it is huge, but definitely well worth looking at.
Peace.
http://www.wymstyle.org/en/
Tim Finley
I’ve worked with a few designers in a similar “framework” manner recently, though I think we may have pushed things too far. We didn’t only share the overall layout and branding for a few sites, we also shared the same “widget” styling (think page navigation, header, footer, list of user names, form layout, etc).
Some times that would work really well since the hard cross-browser work of one person was applied to many pages, but things got very hairy when you nested these CSS widgets inside one another (especially when you added your own page specific tweaks here and there). The problem was that we couldn’t use the ‘>’ operator to select a child element (stupid IE) and had to make rules too general.
We were trying to make clean CSS selectors with as few class names as possible (think ul.tagcloud li a), but when you nest rules like that you get all kinds of crazy overlap from overly generic element selectors.
I still think that our effort was useful, but consistent CSS implementations would make this much easier.
Christian Crumlish
Given that the article leads off by saluting the (fantastic) YUI along with other front-end engineering frameworks, I’d like to direct your readers’ attention to the Yahoo Design Pattern Library (http://developer.yahoo.com/ypatterns/). The YUI and YPL are closely related and we are working on making them even more useful for designers, developers, and hybrids.
Kevin Davison
This is a great article, and very relevant to what I’m working on right now. It seems like I learn something new after every new site produced to come closer to the subject of this article, but I don’t have the luxury of working on a mega-site like Yahoo yet to cooperate with frameworks that really make a difference.
What I do know is that this pursuit makes production much easier to keep things simple, clean and as standardized as possible so engineering can program exactly what we intended. However, the designs I produce tend to be so pixel-precise and intricate with multiple font decorations per line and slight alterations designers love to include. My pursuit of standards and frameworks break down by the time we launch because of all the little page-level tweaks to keep things pixel-perfect. Do sites that focus on less highly-designed Web content have less trouble adhering to standards and frameworks?
Brian Blanton
I really enjoy the articles on this site, and am still amazed how the internet can give you access to so many cool people. I live in Charlotte, NC and am having trouble hooking up with other people to discuss this stuff.
Anyway, one thing I started doing is using the code completion in my text editor to write my standard css files for me. Think of custom textmate bundles for writing certain parts of your css file. (I’m on windows at the moment, so I use http://www.e-texteditor.com/, but it works the same more or less).
So if you are going to use left navigation, maybe you create a shortcut named xxleftnav or xxrightnav for right navigation and so forth. If you’re like me when you work on new sites you tend to have the same layout structures which lend themselves to a library of css layout templates. Enjoy, Brian
Alex Ozga
Great article, I think it would be a good idea for me to make a CSS framework.
You rightly mention that multiple stylesheets can have a significant impact on performance, and that one stylesheet it a solution, but say this is inconvenient to update. I don’t think it would be as bad as you make it out to be, and in my opinion this would be best if the stylesheet was well commented.
Jeff Croft
Hey Alex, thanks for your comments! I think it’s simply personal prefer as to whether people like maintaining one long CSS file or a handful of shorter ones. I like breaking them out, but I definitely know people who like one long one better. So, to each his own.
The other downside of one long file, though—besides maintenance—is that you can’t include only bits of the framework, you always have to include the whole thing. Depending on the framework you create, this may or may not be an issue, but it’s something to think about.
I think the ideal solution is to allow for multiple files but have a server-side process that concatenates them together and sends only one long file to the browser.
Gordon Brander
Hey all,
After reading Jeff’s article, I put together a simple framework using paradigms I’ve found helpful in most of my projects (I’d been thinking about it for a while, but the article convinced me to bite the bullet).
I’m releasing it under GNU in hopes it might be useful to others too. I’m calling it Taffy (Every framework needs a cute name, right?). Hope it helps out, if not as a framework, at least as another example.
Check it out here: “Taffy Framework”:http://www.gordonbrander.com/taffy-framework
Laura B.
I’m not a web designer, just some idiot who has time to much around with her own site. But, this is something I was looking for two years ago when people started talking about CSS and XHTML and having sites that were accessible. I’m glad to see someone thinking about it who actually knows what they are doing. I’d love to have a frame. Especially right now as I have still not fixed my code, mainly because I’ve had less time and less patience and after all it is just my pet project. Hardly anyone but me knows about it. :)
Armand rousso
I have seen many design teams using framework and specially offshore team, in order to keep them not to far from what was required we suggest framework. Armand Rousso
Dale Clarke
A clean usable set of code to do header, menu, 2 and 3 col body, and footer available in a forum is doable. Someone who has asked needs to take and volunteer to moderate it and we can tean to create content. 1ho volunteers? ((-:
5ale on my blkbry in Oceans 13
John Lascurettes
If you create a frameworks of multiple CSS files and concatenate them in one long file, server-side, you are saving the HTTP requests and lightening the load on your server; but you are creating a scenario where you are potentially creating many different on-the-fly, unique css files that are long and different page by page. In other words, the client must download them each time because they will not be recognized as cached (even though they are using the same chunks of frameworks). On top of that, for every unique sheet that’s not seen as being cached, the client will download all those bits and bytes again—more tax on your server.
If you use the individual framework components as separate files, you are taking advantage of caching in the client, but then you are creating a server load as the clients tax the server with HTTP requests to see if their cached versions have been updated on the server or not.
Seems like the server-side solution could be a good one as long as you limit the number of permutations of unique files that the server-side solution would serve up.
Joseph McMurry
While this is a great article, it could use more examples. I really hate to see the multiple http request problem not solved. I would just create in PHP (or your language of choice) one file that includes all the others (e.g. using php’s include function) – at least that will reduce the network overhead.
Mathew Browne
In the past I have merely copied, pasted and modified working CSS from past sites when designing new ones with a similar layout, so moving to a framework is a logical step. Thanks for bringing Yahoo’s UI library to my attention, too – it looks incredibly useful. I look forward to cutting out time working out issues like why my div is 2 pixels to the left in IE and having fun getting back to actually designing!
Jon Henshaw
If you use “TextMate”:http://macromates.com/ , you can specify the default content when creating new files types. For example, you can edit the template that creates new XHTML Strict 1.0 documents to already have the structure you prefer (like including YUI CSS links, etc…).
I then use “Snipplr”:http://snipplr.com/ and their “TextMate Bundle”:http://snipplr.com/extras/textmate/ to easily pull in my own code snippets or favorite code snippets. The bundle saves those snippets offline in TextMate, which is useful if I’m coding offline. The combination of TextMate and Snipplr is my framework.
Darren Jones
Good article, this is something that I’ve been thinking about quite a bit recently. Most of it seems like common sense, but then all the best ideas do. I agree with Jon Henshaw above with regard to ‘implementing’ this framework.
I have a few core CSS files that I always start a site with:
The last one will eventually have all the main styles in, but it starts with some basics that I always use (styles for links, setting font size to 62.5% etc) and then I build on this.
Any common code that I often use is saved as snippets for use with the Scribes text editor. For example I have a nice snippet that creates a tabbed navigation bar within a few keystrokes – it makes development much quicker.
Zack Katz
Yes!
František Malina
This si a text grabbed from my guidelines
Site-wide blocks like sidebars, navigations and complex forms included after the content section. My ideal positions of the code blocks in the <body> are as follows:
1. Header — contains logo (image) and concise slogan (text) of the site. Header can also contain few links to the most important navigation sections of the site (2-5 links) and breadcrumb trails. It is important to keep this information first for branding and accessibility. This also tells the search engine which pages are the most important.
2. Content — starts with heading 1 and continue with the copy paragraph text, headings (2, 3”¦), unordered and ordered lists”¦ If the content contains semantic blocks, these should be wrapped in a div. Example: information about one product in a group of products should be enclosed in a
<div>. This<div>can contain heading with the link to the product page, image of the product and paragraph text with the product description. More information about the content and copywriting has been in the copywriting guidelines document.3. Secondary content — if you have one, it is usually the non-site-wide navigation specific for the current section
4. Sidebars — should contain site-wide-navigation and all the site—wide search forms and similar stuff. The ideal structure of the navigation is unordered list
<ul><li>”¦</li></ul>or nested unordered list<ul><li>Section<ul><li>Subsections</li><li>another subsection</li></ul></li></ul>in case you have sub sections. If the sections contain many other sub-sections, you should put this in a separate list to the secondary content. See ““http://css.maxdesign.com.au/listamatic/”:http://css.maxdesign.com.au/listamatic/ to find out how to give your list-based navigation the look you need.5. Footer — contains the most generic information. Footer may contain information about author/owner of the page enclosed in the
<address>tag. The<address>should contain full address, e-mail and telephone number. You may want to add more semantics here using VCARD format. To include an address is espacially important for local business sites to make the page rank for local terms: “Type of the business and name of the location”? (E.g.: Travel agents Swindon, PPC Warrington) and ensure user can easily find contact details. Footer can also contain link to T&C, Site-wide sitemap and copyright/licence information.6. Wrapper – Everything is wrapped in the wrapper to make it easier to create which has its
position:relativeto make the layouts easier withposition:absoluteEvery layout style sheet than looks like:
<br /> *{margin:0;padding:0}<br /> body{}<br /> #w{}<br /> #h{}<br /> #c{}<br /> #s2{}<br /> #s{}<br /> #f{}<br /> .class1{}<br /> .class2{}<br /> ...<br /> #c p{}<br /> #c ul{}<br /> ...<br /> #s ul{}<br /> #s li{}<br /> #s ul ul li{}<br />Colours and backgrounds are often separated in the stylesheet called theme.css
If anyone fancy I’ll write an article about my field tested madular CSS/XHTML strategy.
Mulyadi Oey
This is a good article. Thank you.
My main concern is that how are we going to communicate the existing styles to the other designers for reuse? More often than not, the styles do not get reused simply because they are hard to find. Should we create some sorts of documentations (e.g. screenshots) for every major style?
Stephanie Hobson
This is a great article to get us thinking. I really like the idea of standardizing our approach to CSS.
To your list of 5 basic style sheets I might add one for microformats since there are some basic styles I generally end up applying to them and the classes are 100% predictable.
I worry that class names like “tabs” aren’t semantic. I haven’t played around with it myself (I have a full time day job maintaining one site) but I’m wondering what your thoughts are on starting with a predictable basic XHTML layout that has common semantic class/id names in it like a header area with a nav list in it by default and then grabbing an applying different basic style sheets (or parts of sheets) depending on how you want those formatted.
Aaron Murray
Vox wrote a server-side solution to concatenate all their .js and .css files into one each for the client.
http://www.slideshare.net/miyagawa/how-we-build-vox
Start at slide 47. Not much on the detail side, though. Wouldn’t be very difficult, though.
Aaron Murray
Vox wrote a server-side solution to concatenate all their .js and .css files into one each for the client.
http://www.slideshare.net/miyagawa/how-we-build-vox
Start at slide 47. Not much on the detail side, though. Wouldn’t be very difficult, though.
George Huger
I really enjoyed this article, and immediately wanted a solution for concatenating all my css files. Basically I wish @import had less side effects.
So I wrote one, and made it public for anyone else who wants to use it:
http://www.georgehuger.com/cssAutoLoad
10KB PHP file and 2 lines of .htaccess, and you’re off to the races. Supports caching, basic compression, and even a little debug.
I’d like to hear feedback, as I’m new to this sort of thing. Thanks again for the inspiration.
Cheers,
George
LeMel LeMel
On HTTP connections vs. stylesheet size, what’s wrong with using @import in a CSS 2.0 world? Cascading is supposed to be a core feature—it’s the ‘C’ in CSS after all.
For the framework I built for our developers, there is a basic.css. More advanced stylesheets
import the BASIC.css. Some have multipleimports to other css ‘modules’, for example, TOOL.css imports BASIC and GRID (GRID imports TABLE), while GUIDE.css which doesn’t need GRID only imports BASIC and TABLE.As long as you keep the functionalities simple and nested, developers only see a few choices (TOOL, GUIDE), and the cascade logic takes care of the rest, while giving me the ability to add new modules or styles only where needed without steadily increasing BASIC.
I’m sure some more advanced folks will let me know why this is bad somehow, but it has worked here for a few years in our (admittedly homogenous) environment (an intranet).
Peter Michael
As many others, I really like to keep it minimal. But even at minimal, I tend to use at least three CSS files. Basics, IE fixes and then the rest. I’ve never used a framework and probably never will. Good article tough, many points i’ve not know of. Thanks!
bobro
I know it’s been a while since you’ve written this article, but I wanted to tell you thanks for taking the time to share your experience. We have been getting a lot of requests for larger MVC sites that are very complex from a GUI perspective (not to mention the programming aspect), and we are definitely seeking an optimal approach with our CSS and designs, as we’ve been spending a lot of time looking at each other’s CSS and going, “huh?” and “what the …”.
Your article is just what I was looking for.
jeffsturgis
You said:
Have a server-side process that dynamically flattens the individual files into a single response. I’ve not seen this done, but it could be very efficient if done well.
Actually Google Pagespeed project supplies code that can be used to flatten and minify your css into a single request.