How to Choose the Right CSS Framework for Your Website
If you're going to build a website with a lot of pages, using some type of pre-built system or framework can help to take care of the drudge work of web design. Frameworks do things like compute the widths for columns, set typographic rhythms, and ensure that all your pages have the right doctype, character set, and scripting languages attached. But with hundreds of frameworks available, how do you choose the one framework that's best for your website?
This article discusses what CSS frameworks are, what they typically include, and considerations you should take into account when choosing a framework. I'll also briefly review some of my favorite CSS frameworks. Understanding how frameworks improve websites can help you to choose the perfect framework for your site.
What Is a CSS Framework?
A CSS framework, also called a web framework, is a group of tools, libraries, and best practices for use on a website. A CSS framework can be as simple as a one-page template that you use as the starting place for every page of your site, or it might be a complex group of CSS, HTML, JavaScript, and server-side programs and files that you use to manage the entire site architecture. But nearly all frameworks include a few things in some fashion:
- CSS resets
- CSS grids
- Typography
- Colors
- Plug-ins and custom user interface (UI) elements
Let's look at some options these features offer for your website.
CSS Resets
Modern web browsers differentiate themselves by tweaking how they display site features. One browser may indent lists by 40 pixels, while another indents by 42 pixels. Some browsers include a border on the <body> HTML tag, while others include padding. You can build a page with very explicit CSS and still be surprised by how different it looks in two different browsers.
CSS resets attempt to fix this problem by bringing all the website elements to a baseline, usually with no styles on each element at all. With everything displayed the same way, you can work from this "blank canvas," using your CSS to make all pages look the way you want. Most web frameworks contain some type of CSS reset.
Some CSS resets, such as Eric Meyer's CSS Reset, are very inclusive and make every element virtually identical. Others, like HTML5 Doctor's HTML5 CSS Reset, leave styles you expect, like the <strong> tag for bold and the <em> tag for italic, but normalize many other tags. Another option is to use this very simple CSS reset:
* { padding: 0; margin: 0; }
This instruction clears out the default margin and padding on all elements, ignoring everything else that's standard about the tags.
Grids
Grids are another tedious part of web design. If you build your own grid, you'll get very familiar with your calculator as you figure out the best proportions for columns and gutters on your site. In fact, a lot of novice web designers don't build their own grids at all. But if you don't use a grid in some fashion, your designs will suffer for it.
Grids help designs look consistent and easy to understand. They give the design structure and clarity. Plus, using a grid makes it easier to replicate the design later.
Several of the first templates available for web designers were of grid systems. One of the best known is the 960 Grid System. This grid was based on a fixed-width layout of 960 pixels. You can build web pages with it using either a 12-column or 16-column grid.
Typography
Creating appealing typographic rhythms on a website can be challenging. It's easier just to select a font family or two, set the base font size, and then move on. Many frameworks include typographic adjustments like fixing line height, adding/removing element padding, and ensuring that headings flow in size as well as font family.
Colors
Many web designers expect to have complete control of colors on a website. Do you know what it means for colors to be complementary or analogous? If not, perhaps you should use one of the many frameworks that provide a baseline for using colors effectively. (Not all frameworks provide color guidance.)
Plug-Ins and Other Custom UI Elements
Some of the more complex frameworks offer plug-ins, scripts, and custom user interface elements. If your site needs special features like a photo gallery, tooltips, collapsible sections, or other scripted UI elements, you might save time by using a framework with such built-in elements.
What You Should Consider Before Choosing a Framework
There's more to choosing a framework than just knowing the options it offers. You'll need to consider factors like these:
- What type of framework your site needs
- Framework language
- Framework features
- Whether the framework is customizable and modular
The following sections review some of the main issues to consider.
What Type of Framework Do You Need?
First you need to know something about your site. Does it really even need a framework? Most sites with multiple pages benefit from frameworks. The exact number of pages can vary, but if you find yourself repeating the same HTML, CSS, or JavaScript on all your pages, a template or framework could help.
Framework Language(s)
You should know the computer language(s) your framework uses. As I mentioned earlier, some simple frameworks are just basic HTML templates, and more complex frameworks might include CSS and JavaScript. Some frameworks use Less or Sass to compile the CSS; others use Ruby or other programming languages to compile the pages once you're done building them. If you don't know the language(s) your framework uses, that framework will be challenging to implement.
Additional Options Your Site Might Need
Go through the features I've listed so far, and decide which features your site needs and which ones aren't necessary. Then consider whether your site needs these additional options:
- Responsive Web Design (RWD). These days, if a site isn't responsive, it won't do well. So if a framework isn't responsive, it's not a good choice. (See my article "Responsive Web Design Is More Than Just Media Queries" for details on making your websites responsive.)
- Mobile-friendly and mobile-first design. Some websites need to be mobile-friendly, and others need a more mobile-centric or mobile-first design. Your framework should reflect that focus.
- Browser support. Some frameworks support old versions of web browsers, but others don't. For instance, BlueprintCSS may even support Internet Explorer version 5, while most other frameworks stop backward compatibility at Internet Explorer version 7.
- JavaScript requirements. Many of the larger frameworks require specific JavaScript libraries. For instance, Bootstrap and Zurb's Foundation both require jQuery.
Is the Framework Customizable and Modular?
Customizable frameworks let you add your own code to make your site look like something you built, rather than like other sites out there. But if a framework is too customized, you lose the benefits of a framework; you might as well just build the site from scratch.
Modular frameworks take customization into account. Most modular frameworks offer a base system, to which you can add features as needed. For example, Bootstrap offers many JavaScript scripts you can add to your site. If you never plan to use a carousel, you can compile Bootstrap without the carousel.js code, but the carousel is always available if you need it.
Some of My Favorite CSS Frameworks
If you're not sure where to start with the many available CSS frameworks, take a quick look at a few that I particularly like.
960 Grid System
The 960 Grid system is an HTML template and a CSS file that you can use to create 12- and 16-column grids on 960-pixel fixed-width layouts. The designers chose that width because modern monitors support at least 1024×768 resolution, and 960 is a number that's evenly divisible by 2, 3, 4, 5, 6, 8, 10, 12, 15, 16, 20, 24, 30, 32, 40, 48, 60, 64, 80, 96, 120, 160, 192, 240, 320, and 480—making 960 a very flexible number to use for devices with various screen widths. The biggest problem I have with this framework is that it isn't responsive out of the box; you have to get an alternate version like Foldy960, which is a responsive update to the 960 Grid system.
Blueprint
Blueprint is a CSS framework that offers grids, typography, styles for forms, and print layouts, as well as plug-ins to expand your pages. One of the most interesting things about Blueprint is that you can use it with Ruby and the script compress.rb to make your CSS classes semantic, while keeping the presentational classes that Blueprint uses. For more information, read Josh Clayton's article "Blueprint's compress.rb: A Walkthrough."
Bootstrap
Bootstrap offers a lot of power and flexibility for website designers. This large framework includes a grid, typography, colors, and many plug-ins and scripts. It's responsive, and it offers a lot of the features that people want from a framework.
Compass
Compass is a server-side framework that uses Sass to create semantic web pages with clean CSS code. Compass can be a little overwhelming for designers who are less code-savvy, because it uses a command-line interface for most interactions. But you can buy a GUI that interacts with it.
Foundation
Zurb's Foundation is a powerful front-end framework that uses Sass to compile the CSS. It builds pages quickly, and the pages it creates are fast-loading for customers.
HTML5 Boilerplate
HTML5 Boilerplate is a basic-but-useful HTML5 template you can use to get your pages started quickly. It isn't as robust as some of the larger frameworks, but if all you need is rapid setup with a mobile-friendly template and some scripting libraries, this is a great solution.
Kube
Kube offers a simple framework with responsive design, a flexbox grid, horizontal rhythm, and gorgeous typography. This is a great framework for sites that need more features than a template offers, but want to avoid code bloat.
Pure CSS
Pure CSS was created by Yahoo! as a way of adding simple CSS modules to any web page or website. It's meant to be not just small, but tiny. If you grab the entire thing minified and gzipped, it comes in at a minuscule 4KB. This makes it the perfect framework for a mobile design.
Responsive Grid System
The Responsive Grid System is a good tool to use if all you need is a responsive grid. You can use it to create any number of columns or scale to any width. The breakpoints are already baked in, so you don't have to worry about that (unless you just want to).
Skeleton
Skeleton is another very simple framework that provides a responsive boilerplate for building site design. It includes a grid; typography; styling for buttons, forms, and lists; and a few utility classes.
Many More Options Are Available
If these frameworks don't appeal to you, or they don't meet the needs of your site, don't worry. You can find many others choices by searching the Web. Be sure to share in the comments some of your favorite frameworks!