What is a CSS Framework?
- A framework is a basic (usually abstract) conceptual structure which you can use as a “scratch” for your web-projects. For instance, instead of defining global reset, consistent baseline, typographic rules or basic styles for forms over and over again — every time you work on a new project — you can prepare a default-style once and reuse it in all your future projects. This is what you call a CSS Framework.
- CSS frameworks don’t have to be complex or large, they may contain a set of simple CSS-styles such as
- typography.css for basic typographic rules,
- grid.css for grid-based layouts or
- layout.css for general layouts,
- form.css for basic form styling,
- general.css for further general rules
and so on. In your code segmentation you can also go further, for instance: structure, typography, design presentation, specialist sections (e.g. menus, navigation), print, mobile web, tweaks (mostly old style browser hacks), browser specific workarounds (via IE conditional statement). “On the whole code segmentation in frameworks is handy to work with, but it can add some real load to a server with the extra http request per page view.” [Treading Lightly With CSS Frameworks, by Gary Barber]
- “[Framework is] a set of tools, libraries, conventions, and best practices that attempt to abstract routine tasks into generic modules that can be reused. The goal here is to allow the designer or developer to focus on tasks that are unique to a given project, rather than reinventing the wheel each time around.” [, by Jeff Croft]
Advantages of CSS Frameworks
- You increase your productivity and avoid common mistakes.
If you develop several sites of the similar nature, an abstraction of CSS code can dramatically speed up your productivity, help you to avoid common mistakes and simplify the management of CSS code.
- You normalize your code/class base.
You have a common “default” CSS-code and (X)HTML-markup, so you always use the same IDs and class names in your projects. Code consistency throughout a number of projects makes it’s easier for you to maintain a web-site without digging into the source code of every project you’ve ever worked on — to understand how you’ve actually built the web-site.
- You have a better workflow within a team.
If a CSS-framework is well documented, it can be used within a team as a common ground-up; thus you can avoid misunderstandings and ensure an optimal workflow. The latter results in avoiding mistakes and helps you to meet deadlines without compromising on product quality and without overtime costs.
- You gain an optimal browser-compatibility.
Since your CSS-framework is “bulletproof”, you don’t have to worry about browser-compatibility issues and can start coding right away.
- You have a clean, well-structured and complete code.
CSS Frameworks provide you with a well thought-out foundation for your sites; using them you have the basic styling of all html-elements you’ll ever need to style from the very beginning of your projects. Have you ever forgotten about code
or abbr
? That’s the point.
Disadvantages of CSS Frameworks
- You need time to fully understand the framework.
“For the average user, [..] the time required to understand the architecture of the framework far outweighs the menial task of coding it from scratch.” []
- You need a close familiarity with your code’s architecture.
Using external CSS frameworks, you still need a profound understanding of your code. You need to know exactly how your framework is actually built. “By building a site from the ground up, you gain a knowledge of your site’s architecture that can’t be learned through any study or documentation.” []
- You might inherit someone’s bugs or mistakes.
If you use external CSS Frameworks you might get in trouble fixing someone else’s bugs which is far more time-consuming than fixing your own bugs.
- You develop sites upon a framework, not upon the solid knowledge of CSS.
“A big problem with frameworks is when up and coming developers attach themselves to a framework as opposed to the underlying code itself. The knowledge gained in this case surrounds a specific framework, which severely limits the developer.” [, by Jonathan Christopher]
- You get a bloated source code.
“Whether it be in a server side language framework or JavaScript library, there is often a large percentage of code that will never be executed. While not a major issue server side, this can greatly degrade the performance of a client side framework such as a JavaScript library.” [, by Jonathan Christopher]
- CSS can not be framed semantically.
“CSS and (X)HTML go hand in hand. (X)HTML is a language semantic in nature, which is impossible to wrap up in the style of a framework. Each and every project is unique in and of itself, right down to the document structure, classes, and ids. A CSS framework passively removes a great majority of semantic value from the markup of a document and, in my opinion, should be avoided.” [, by Jonathan Christopher]
- Ignoring the uniqueness of your projects.
Designs should be based upon the content, not upon a standard template you use over and over again.
CSS Frameworks
Dirk Jesse’s extensive (X)HTML/CSS Framework offers the whole bunch of default-templates for a number of simple or more complex web-projects. YAML is based on web standards and supports every modern web browser. All Internet Explorer’s major rendering bugs are countered. YAML fully supports all IE versions from 5.x/Win to 7.0.
Apart from a number of standard-conform layouts the framework also offers a debugging stylesheet, print stylesheet as well as various robust tools for web-development in YAML. All CSS components of the framework as well as the various layout methods are thoroughly documented in both English and German, supplemented by numerous examples.
You can also use a to develop your layout visually - in your web-browser. You can choose a Doctype, basic layout elements (#header, #footer, …), the number of content columns as well as preferred column order and set the layout and column widths. You can also drag & drop and nest both sub-templates and dummy content, display and output the complete code (XTHML markup and CSS) and switch between draft mode and preview of the finished layout.
The Blueprint CSS framework, created by Norwegian tech student Olav Frihagen Bjørkøy, is a foundation for developing typographic grids using CSS. The framework offers an easily customizable grid, sensible typography, a typographic baseline and a stylesheet for printing. It also uses relative font-sizes, provides a CSS reset and is supposed to be cleaned of code bloats. The latter .
Besides, you can also use the to generate more flexible versions of Blueprint’s templates. Whether you prefer 8, 10,16 or 24 columns in your design, this generator now enables you that flexibility with Blueprint CSS Framework - a new “to-become-standard” in grid-based design approach.
Yahoo! UI Library CSS Foundation
Yahoo! UI Library presents a set of CSS frameworks: the core YUI CSS foundation includes the Reset CSS, Base CSS, Fonts CSS, and Grids CSS packages.
While Reset CSS removes and neutralizes the inconsistent default styling of HTML elements, Base CSS applies a consistent style foundation for common HTML elements across A-grade browsers.
Fonts CSS offers cross-browser typographical normalization and control; the framework provides consistent font sizing and line-height, supports user-driven font-size adjustment in the browser, including cross-browser consistency for adjusted sizes and works in both Quirks Mode and Standards Mode.
Grids CSS delivers four preset page widths, six preset templates, and the ability to stack and nest subdivided regions of two, three, or four columns. The 4kb file provides over 1000 page layout combinations. The framework supports easy customization of the width for fixed-width layouts; it also supports fluid-width (100%) layouts as well as preset fixed-width layouts at 750px, 950px, and 974px, and the ability to easily customize to any number. YUI also offers The YUI Grids Builder — a simple interface for Grids customization.
You should be aware that these frameworks for bloating the code with non-semantic markup and generating too many unnecessary classes, IDs and div-containers in CSS. Yahoo! UI Library also provides a detailed documentation with numerous examples, tutorials, cheat sheets, templates and tools.
CSS Global Reset (CSS Baseline)
- Global Reset is needed to ensure the more or less identical cross-browser presentation of your web-sites. By default different browsers use different values for margin, padding or line-height. Global Reset makes sure all (or probably most) browsers render sites identically.
- * { margin: 0; padding: 0; } is a bad practice.
“Unfortunately, this isn’t a good practice. It’s very heavy on the rendering agent to apply rules to every single element in the document, especially with large web pages, and this can also destroy a lot of good default styling, especially when you want to have default styled submit buttons.” [ by Christian Montoya]
Tripoli is “a generic CSS standard for HTML rendering. By resetting and rebuilding browser standards, Tripoli forms a stable, cross-browser rendering foundation for your web projects.”A set of default-CSS-files is supposed to give you a profound foundation for cross-browser compatible CSS-based designs. All default-values - including dozens of elements - tables, lists, typography, but also headers (h1 - h6), abbreviations, citations, quotes and forms are selected to enable an optimal legibility and well-structured text presentation.
- by Eric Meyer
A “reset” or “baseline” set of styles, not based on the universal selector. As Meyer says, “the styles should list all the actual elements to be reset and exactly how they should be reset.”
- Yahoo! UI Library: Reset CSS
YUI Reset CSS file removes and neutralizes the inconsistent default styling of HTML elements, creating a level playing field across A-grade browsers and providing a sound foundation upon which you can explicitly declare your intentions.
- by Kyle Neath
A simple CSS reset with some additional classes for better debugging.
- by Christian Montoya -
“It’s far better to have a complete list of default settings to apply from the beginning that targets the specific browser inconsistencies.”
- CSS Global Reset by Mike Rundle (currently unavailable)
- Master Stylesheet
This default-stylesheet takes some typographic rules into consideration, such as the spacing between heading tags, paragraphs, and blockquote elements.
CSS: Basic Styling
- Web Typography: bottom margins of paragraphs and lists by Marko Dugonjic
“The basic unit of vertical space is line height. Establishing a suitable line height that can be applied to all text on the page, be it heading, body copy or sidenote, is the key to a solid dependable vertical rhythm, which will engage and guide the reader down the page.”
- by Darren Hoyt
- by TJKDesign
There is a possibility of breaking down stylesheets into components that could be reused across projects. The next logical step is to extend this to become a CSS framework, allowing rapid development of sites with pre-written and tested components. All that’s really required to produce this is a set of naming conventions and a flexible base template…
Develop Your Own CSS Frameworks!
Keep your CSS frameworks as abstract as possible. Usually the global reset style and basic formatting rules are a sound compromise which will give you a though-out starting point and won’t bound you to the rigid structure of the framework.
Developing your own default-styles, keep the numbers of classes, IDs and used html-elements to a minimum; keep the importance of semantic meaning of the classes in mind.