Modernizr progressives or exceptions?

Modernizr, what an interesting tool you are. How do I use your class names in my CSS files? You’ve given me a choice and I’m not sure what to use:

.multiplebgs div p {
  /* properties for browsers that
     support multiple backgrounds */
}
.no-multiplebgs div p {
  /* optional fallback properties
     for browsers that don't */
}

There are two ways to view this, bottom up, and top down. They both have their advantages and disadvantages, and I’m going to attempt to highlight these for you, so you can make your own decision.

Bottom up

For the “bottom up” way of doing things, we define a lowest common denominator. A set of styles that will work with all the browsers your website is designed to target. The intersection of all the features of all your browsers, if you want to put it that way. From here, we use Modernizr to progressively enhance the user’s browsing experience for browsers that support particular features. An example may help:

a.btn {
  background:transparent url(../img/btn-red.gif) no-repeat scroll 0 0;
  padding:5px;
  display:inline-block;
  width:40px;
}
.borderradius a.btn {
  background-color:red;
  background-image:none;
  border-radius:5px;
}

The advantages being:

  • A clearly defined baseline that works on all browsers we’re coding for
  • If we aren’t able to determine client features (because for example, Modernizr is not available: the CDN is down, or the client doesn’t have JavaScript enabled) we know that the baseline styles will be used and will ensure the site looks acceptable regardless

The disadvantages are:

  • We end up writing more and more CSS as we utilise new features that become available
  • It doesn’t encourage a particularly forward thinking coding practice. You’re essentially coding for the browser with the lowest feature set
  • If you want to change the baseline styles because of a redesign or perhaps your baseline is raised, you’re probably going to have to change overridden styles in the progressive enhancement style blocks as well

Top down

The “top down” approach is where we define styles for new browsers, and then use the “no-” prefix classes to define exceptions for browsers that don’t support the feature we’re exploiting. e.g.

a.btn {
  border-radius:5px;
  background-color:red;
  padding:5px;
  display:inline-block;
  width:40px;
}
.no-borderradius a.btn {
  background:transparent url(../img/btn-red.gif) no-repeat scroll 0 0;
}

We’re forward thinking, assuming everyone viewing our site is using these great new features and coding in fallbacks for the exceptions to the rule. Our view is that one day, all browsers will support the styles we’re using…and we’re adding in exceptions for in the mean time. The advantages are:

  • We end up writing less CSS, as we don’t have to override properties we’ve previously declared that the browser doesn’t understand
  • Our mindset is altered slightly, encouraging us to make use of and exploit new browser features that allow us to code and prototype faster
  • As our browser baseline increases, it’s really easy to remove exceptions that are no longer used

The disadvantages are:

  • We’re totally relying on Modernizr and the browser having JavaScript enabled. Without JavaScript the “no-” prefixed classes are not added to the <html> element and the browser is left trying to style things that aren’t supported or use style declarations that don’t exist (as far as the browser knows).

Well, sort of. You could always use the “no-js” class on the <html> element which Modernizr normally removes and replaces with “js” (to indicate JavaScript is available). You’d define your styles as above, but then define a lowest common denominator style set, for when you don’t know what features a browser does or doesn’t support. That’s kind of overkill though.

So, that’s basically it. When I first thought about it my gut reaction was to sit in the bottom up camp, but after thinking about it, and considering the audience for the project I’m working on it makes more sense to use the top down approach. Especially now that I’ve written it down like this. I’m hoping it’ll help others to make the right decision.

14 thoughts on “Modernizr progressives or exceptions?

  1. Pingback: Tweets that mention Modernizr progressives or exceptions? | freestyle developments -- Topsy.com

  2. Hi Alan,

    Original creator of Modernizr here, wanted to thank you for writing this up, it’s a useful resource! I’m glad you went the Top Down approach, that is generally how we recommend using Modernizr but thus far we haven’t had a simple, clear resource explaining the differences to point to. Now we have.

    Our reasons for preferring Top Down are the advantages you listed, but also: it creates a very clean and clear separation between what is our desired markup and CSS, and what is there only to serve as a fallback. Separating fallbacks from goals is a really good practice to get into, and a great mindset to have.

    Lastly, we also consider the disadvantage minimal; yes, there are people with no JavaScript or for whom it is proxy-filtered out, but the reality is that the Web going forward will need JavaScript if it is ever to progress and flourish. As long as we make sure that core content is at least accessible without JavaScript, then everything should be okay to need JavaScript (in our opinion). That includes a nicer looking design and better interactivity and navigation. It’s for the sake of the Web in the long-term without sacrificing too much on the short term.

    Thanks again!

  3. I’ve mostly used Modernizr as a way to catch exceptions, so more of the top-down approach. It results in the most clean CSS and is easier to debug if something goes wrong.

  4. Definitely a top-down kind of guy. I code for functional/capable browsers and use fallbacks/exceptions for the less-capable browsers.

  5. I see you share interesting stuff here, you can earn some
    additional cash, your blog has huge potential, for the monetizing method,
    just search in google – K2 advices how to monetize a website

  6. buy priligy online These women include those who are significantly overweight with a body mass index of more than 35 and those who are diabetic Diabetes Mellitus DM Diabetes mellitus is a disorder in which the body does not produce enough or respond normally to insulin causing blood sugar glucose levels to be abnormally high

  7. J Pediatr 2003; 142 656 661 where can i buy generic cytotec no prescription I mean pain is even a strong word because it s not painful it s just like oh I feel my kidney

  8. DOLOBID diflunisal like other NSAIDs can cause serious skin side effects such as exfoliative dermatitis SJS and TEN which may result in hospitalizations and even death cost cheap cytotec without prescription If you are taking iron supplement then have a talk with doctor

  9. Rakoo Casino bietet eine Vielzahl von Zahlungsmethoden, darunter PayPal und paysafecard, um den Spielern eine
    sichere Einzahlung zu ermöglichen. Diese hohen Quoten bieten den Spielern bessere Gewinnchancen und machen das Spielen noch attraktiver.
    Es gibt spezielle Bonusaktionen, die regelmäßig angeboten werden und
    den Spielern zusätzliche Gewinnchancen bieten.
    Regeln für Neukundenboni und wöchentliche Werbeaktionen ermöglichen es Spielern, von verschiedenen Angeboten zu profitieren.
    Online Casinos bieten zudem Reality Check-Benachrichtigungen an, die Spielern helfen, sich der Spielzeit bewusst zu bleiben. Seriöse deutsche Online Casinos
    setzen auf diese Technologien, um ein Höchstmaß
    an Sicherheit zu bieten. Beispielhafte Anbieter wie North Casino bieten ein umfangreiches Spielangebot und zeichnen sich
    durch hohe Sicherheitsstandards aus, die die Sicherheit
    der Spieler garantieren.
    Es gibt dabei 4 große Lizenzgeber, die Unterlizenzen an Glücksspiel-Betreiber ausgeben. Seit Anfang der 1990er Jahre gibt man hier Glücksspiellizenzen an Betreiber aus aller Welt
    aus. Die folgenden Lizenzgeber hingegen lizenzieren ausländische Casinos, die
    seit vielen Jahren von Spielern in ganz Europa und sogar weltweit aufgesucht werden können. Dadurch entstehen auch jede Menge neuer Glücksspielanbieter, doch stehen sie ausschließlich den Bewohnern des jeweiligen Landes zur Verfügung.
    Ein Bonus Crab Casino bietet seinen Spielern die Möglichkeit, in der
    Regel für geringe Einzahlungen, einen gratis Pick
    bei der Bonuskrabbe zu nutzen.

    References:
    https://online-spielhallen.de/meine-umfassenden-erfahrungen-mit-evolve-casino/

  10. Nach eigenen Angaben umfasst die Spielauswahl im Wazbee Casino mehr als 4’000 Titel.
    Wazbee bittet Familienangehörige und Freunde, auf die Support-Mitarbeiter
    zuzugehen, wenn das Spielverhalten einer nahestehenden Person Sorgen bereitet.
    Spieler können zwischen einen 100% Bonus bis zu 200€ oder einen 150%
    Kryptobonus bis zu 100€ wählen! Das WazBee Casino ist mit einer zuverlässigen Lizenz aus Curacao lizenziert.
    50 Freispiele ohne Einzahlung + 100% Bonus bis zu 300€ + 100 Freispiele Das Casino bietet Vielfalt, Abwechslung
    und Unterhaltung.
    Sehe gutes casino macht viel spass Auszahlung ist sehr schnell aber wenn mal etwas sein sollte ist
    der Support ziemlich schnell und arbeitet effizient !

    Das Wazbee Online Casino bietet dir den sogenannten VIP Club an, der aus zwei
    Stufen besteht. Damit wird das Laden der Inhalte garantiert
    und du kannst dich darauf einlassen, dass deine Spielstände erhalten bleiben. Das umfassende Slotangebot wird im Wazbee Casino auch durch mehr als 500 Tisch- und Kartenspiele ergänzt.
    Egal, ob Fische, Süßigkeiten, Weltall oder Wilder Westen,
    Wazbee Casino bietet viele Optionen. Dank der Kategorien kannst
    du bequem filtern und mit der Suche hast du die Option deine Wunschspiele
    gezielt zu finden.
    Ergänzend zum attraktiven Willkommensbonus erfährst du
    hier, worauf du bei dem neuen Online Casino freuen kannst.
    Bin neu auf Wazbee und habe es getestet bis jetzt bin ich
    zufrieden und schöne Angebote und viel spielauswahl super Es ist ein faires casino es könnte mehr no despoit Angebote geben bis jetzt noch keine Probleme gehabt hoffen wir das das es so bleibt Durch die
    Lizenzierung und Regulierung wird sichergestellt, dass Spielerinnen und Spieler aus Österreich ihre
    Lieblingsspiele beruhigt genießen können, im Wissen, dass ihre Daten und Einlagen sicher sind.

    Mit einer lebhaften Benutzeroberfläche, die den Charme der österreichischen Kultur
    widerspiegelt, bietet Wazbee ein Spielerlebnis, das sowohl vertraut als auch
    spannend ist. Das Casino bietet eine große Anzahl an Casino Spielen an, und
    auch das Design weiß zu gefallen.

    References:
    https://online-spielhallen.de/sofortige-casino-freispiele-der-schnellste-weg-zum-gluck/

  11. Das Bassbet Casino bietet eine große Auswahl an Spielen, die jeden zufrieden stellen. Spielen Sie klassische Tischspiele wie Blackjack,
    Roulette und Poker. Zusätzlich bieten wir umfassende Informationen und Prognosen in unserem Blog, wo du jede Woche die neuesten Sportwetten News
    und Vorhersagen findest.
    Das Spielangebot bei 1Bet Deutschland ist beeindruckend und bietet eine breite Palette
    an Casinospielen, die sowohl neue als auch erfahrene
    Spieler begeistern. Das 1bet Casino ist ein Glücksspielanbieter, der auch Sportwetten anbietet.
    Die Spieler genießen eine reibungslose Erfahrung auf , egal ob sie auf dem Desktop oder mobil
    spielen. Die mobile Website sorgt für ein großartiges 1Bet-Casino-Erlebnis und macht es einfach,
    jederzeit und überall zu spielen. Des Weiteren finden Sie
    in unserem Casino unser Spielautomatenturnier – Kampf der Drehungen und wiederkehrende
    Promotionen, die zusätzliche Gewinne und Freispiele ermöglichen können.
    Damit Sie den Willkommensbonus erhalten, müssen Sie einfach während des Einzahlungsvorgangs den Button für den entsprechenden Bonus durch
    einen Klick aktivieren.

    References:
    https://online-spielhallen.de/monro-casino-deutschland-ihre-anlaufstelle-fur-online-glucksspiel/

  12. Variante des Krypto Willkommensbonus eine attraktive Möglichkeit für alle,
    die ihre Kryptowährungen in ein spannendes Spielerlebnis umwandeln möchten. Wenn du dich hier erkennst kannst du
    von einem 300% Bonus bis zu 600€ für Ersteinzahlungen von 100€
    oder mehr in Kryptowährung profitieren. Dazu bietet der
    Anbieter eine zweite Möglichkeit, deine erste Einzahlung noch mehr auszureizen.
    100% bis zu 500€ + 150 Freispiele Dennoch haben wir uns in der Spielothek sicher gefühlt
    und empfehlen Haz Casino gerne weiter! Freispiele und Bonus sind umsatzfrei.
    Freispiele sind für Ramses Treasures. Mindesteinzahlung
    Sobald Sie die Webseite besuchen, werden Sie von einer ansprechenden Benutzeroberfläche begrüßt, die sehr einfach zu durchstöbern ist.
    Wenn Sie mit einem aktiven Willkommenspaket spielen, dürfen Sie keine
    höheren Einsätze als 4 € pro Runde tätigen, wobei Sie 30 Tage Zeit haben, um dieses durchzuspielen. Neben dem Willkommensbonus bietet Haz Casino auch einen Cashback Bonus, der auf der Summe der
    von Ihnen getätigten Einsätze basiert. Als ob das nicht schon genug wäre, können Sie sonntags auch noch einen 50%
    Einzahlungsbonus bis zu 250 € erhalten, wenn Sie nur 25 € einzahlen.
    Mit einer Mindesteinzahlung ab 20 Euro qualifizieren Sie sich
    für einen der drei Willkommensboni, die insgesamt bis zu 250% betragen, was ein erstaunlicher Prozentsatz ist.
    Jedes dieser Angebote ist mit einem zusätzlichen Anreiz in Form von 125 Freispielen für einen beliebten Spielautomaten verbunden.

    References:
    https://online-spielhallen.de/bregenz-casino-cashback-ihre-geld-zuruck-aktion-im-detail/

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>