// I need to

ModernizeUpgrade without breaking it RescueFix what someone else started Build NewTurn an idea into a product Reach More PeopleGet found, get used, include everyone

// Company

Case StudiesExpertiseAbout + CareersResourcesContact Book a call →

Enter Foundation 4

Why Zurb Foundation beats Bootstrap for responsive front ends, and a quick tour of what's new in Foundation 4.

Art+Logic Mar 18, 20135 min read

From the Art+Logic archive · written in 2013. The tools may have moved on; the thinking still holds.

Foundation Logo - Yeti

My plan for this blog post was to introduce my preferred “front-end framework”, Zurb Foundation. But then the folks over at Zurb saw fit to sabotage my effort by releasing a new version of Foundation. Can you believe the nerve? So instead I’ll just give a quick rundown of why I like Foundation better than that “other framework”, and then show off what’s new in Foundation 4.

Foundation vs. Bootstrap (the short version)

Foundation is better because:

Obviously this is subjective, and others may disagree. Maybe there are even good reasons for using Bootstrap in a particular project (despite Foundation’s obvious superiority).

I think you’ll agree, though, that “yetis” is objectively better than “no yetis”.

Grid Changes

Foundation 4 has been rewritten to encourage “mobile first” development, meaning you build your site for small devices (read: phones) first and then scale things up to support tablet and desktop browsers. The practical upshot of this change is that the CSS class names for columns have changed.

Where in Foundation 3 you might write:

<div class="row">
    <div class="four columns">stuff</div>
    <div class="eight columns">moar stuff</div>
</div>

in Foundation 4, you do something like:

<div class="row">
    <div class="small-4 columns">stuff</div>
    <div class="small-8 columns">moar stuff</div>
</div>

I found this a little annoying, since one of the things I liked about Foundation as opposed to Bootstrap was the fact that I don’t much care for the numbers in the class names. However, the observant will notice that the numbers in this case are prefixed with small-, rather than Bootstrap’s span. Why is this better? Because the existence of small- implies that there’s also a large-, and indeed there is. Consider the following code:

<div class="row">
    <div class="large-3 small-6 columns">Inky</div>
    <div class="large-3 small-6 columns">Blinky</div>
    <div class="large-3 small-6 columns">Pinky</div>
    <div class="large-3 small-6 columns">stuff</div>
</div>

What this means is that on large screens, each inner <div> will take up 3 columns (of 12), and so they will each be displayed on the same row. But on a small screen, each <div> will take up 6 columns, and then the second two <div>s will wrap around below them, so you’ll end up with two rows of two <div>s each.

I don’t know about you, but I think that’s awesome. It’s probably even worth putting up with numerals in my class names.

Foundation 3 just treated small screens as having 4 columns by default instead of 12, so you get a lot more control over exactly how you want things to look on different screen sizes with the new release.

Some other class names have also changed to reflect the small- vs. large- dichotomy, like small-centered, small-offset-#, and small-block-grid-#. You’ll need to update these if you’re moving to the new version.

It’s also worth noting that the large- prefixed classes override the styling for the small- prefixed styles, so if you use only one or the other, use small-. They should work just fine on large screens.

Semantic SaSSyness

Foundation has been using SaSS (ScSS syntax) since version 3, but in version 4 things got a whole lot cooler.

Firstly, using the SaSS features in Foundation no longer requires the use of Compass. You can still use it, of course, you just don’t have to any more.

Foundation 4 also implements the majority of it’s functionality using SaSS mixins, so if you’re one of those purists who despise having non-semantic classes on your HTML elements, you can implement almost everything in terms of SaSS mixins.

(For the record, I’m not one of those purists, but I guess purists need love too.)

Here’s what that looks like with a button:

#your-semantic-id-here { @include button; }

Now your element looks like a standard Foundation button, but there’s no icky non-semantic classes in the HTML markup.

You can do this with nearly every part of Foundation, and the documentation has a fantastic amount of detail on the same page with the instructions for how to use the equivalent pre-built classes. The few exceptions appear to be because certain JavaScript-y bits need to have specific classes to latch onto.

Of course this means you need to do some extra work to build your actual CSS from SaSS, but for some people, this is just what they’ve been waiting for.

Javascript Changes

Zurb has revamped the JavaScript plugins included with Foundation to streamline them a bit, but things are mostly the same here.

One major change, though is that Foundation 4 assumes you’ll be using zepto.js, rather than jQuery. This worried me at first, since while zepto is great if you’re only targeting webkit-based mobile browsers, it is not a drop-in replacement for jQuery. It turns out I was worried for nothing, though. The bright folks at Zurb have written their plugins to be compatible with both zepto and jQuery, so if you want to use JQuery instead, it’s just a matter of loading jQuery rather than zepto in your HTML.

Other Changes

A few other things that jumped out at me:

If you want a blow-by-blow of all the main changes, the migration docs are probably the best place to look.

Finale

All in all, it looks like the new release of Foundation is really quite nice. The new grid features give much more control over display of your site on various size devices. Compatibility with both Zepto and jQuery let’s you use whichever is best for your use case. The SaSS features let you move styling almost completely out of your markup if you want (and of course let you customize almost everything that Foundation does, as well).

Migrating to Foundation 4 might cause a bit of upgrade headache for folks switching from Foundation 3, but it looks to be worth it, especially if your site needs to be highly responsive to both mobile and desktop users. Zurb just keeps making Foundation better and better, and Foundation 4 is no exception.

Even if they did derail my topic for this post.

keep going

More to explore in Reach More People.

All Reach More People resources →
let's talk

Got a problem like this one?

Tell us what's stuck. A real person replies within one business day.

Talk to our team →

Talk to people who know software, not a sales script.

Your first call is with Aja, our VP of Sales. He'll help make sure you're solving the right problem. Here's what you'll cover together:

  1. What you're trying to accomplish

    The business goal first, then the technology.

  2. Possible approaches

    And the tradeoffs of each, in plain language.

  3. Risks you may not have considered

    Technical and business, before they cost you.

  4. Whether AI changes the math

    What's practical, and what's just hype for your project.

  5. Sensible next steps

    Even if the right next step is not us.

book-a-call.ics

Loading the scheduler…

Open the booking page →

Some problems are easier to explain in writing. Send us a few lines about what you're working on, and we'll reply within one business day. Helpful to include:

  1. What the software does, or should do
  2. What's stuck, or what's worrying you
  3. Any deadline or budget you have in mind
note.md

Loading the form…