SlideShare a Scribd company logo
IT’S A MOD WORLD
A PRACTICAL GUIDE TO
 ROCKING MODERNIZR
WHAT IS IT?
“Modernizr is a small and simple JavaScript
library that helps you take advantage of emerging
web technologies (CSS3, HTML 5).”
~from modernizr.com

Tells you whether or not the current
browser has HTML5 and CSS3 features
natively implemented.
THE WHO
Faruk Ateş
@KuraFire

Paul Irish
@paul_irish

Alex Sexton
@slexaxton
WHERE?

• http://modernizr.com
• Follow: @modernizr
• Contribute:
  https://github.com/Modernizr/Modernizr
HOW DOES MODERNIZR WORK?

• Uses feature detection to test browsers for
  support of HTML5 and CSS3 features
• Brings an end to browser sniffing
WHAT DOES THAT MEAN?
BROWSER SNIFF BAD
ol_skool_browser_detect: function() {
  if(navigator.appName==='Netscape' &&
     navigator.appVersion==='5.0 (Macintosh; en-US)'){

        // Do something magical for FireFox Mac users.

    }
}


•       Not reliable

•       Not “future-proof”
I CAN HAZ FEATURE DETECTION?
the_mod_way: function() {
  if(!Modernizr.input.placeholder){
    // No declarative HTML5 "placeholder" support
    add_my_focus_event();
  }
}


•   More reliable

•   More “future-proof”
USE HTML5 SEMANTIC ELEMENTS

• Allows you to use semantic HTML5
  elements (same as html5shim/html5shiv)
• Renders block level elements as divs in
  non-supporting browsers
• Allows you to style elements in your CSS
MODERNIZR DOES NOT

Modernizr does not add missing
  functionality to browsers
UNDER THE HOOD
 Tests over 20 HTML5 and CSS3 features

• Modernizr tries to create and do
  something with new features in the DOM
• Browser understands: yay support!
• Browser does not understand: ahhh
SOME PHILOSOPHY
PROGRESSIVE ENHANCEMENT
Progressive enhancement is a strategy for web design that emphasizes
accessibility, semantic HTML markup, and external stylesheet and
scripting technologies. Progressive enhancement uses web technologies in
a layered fashion that allows everyone to access the basic content and
functionality of a web page, using any browser or Internet connection,
while also providing those with better bandwidth or more advanced
browser software an enhanced version of the page. ~from wikipedia


•   Use semantic markup

•   Take advantage of great stuff in the experience layer
DO WEBSITES NEED TO LOOK THE
   SAME IN ALL BROWSERS?
ANSWER
http://dowebsitesneedtolookexactlythesameineverybrowser.com/

                                Thanks Dan Cederholm @simplebits
CONTROL
• Take advantage of new HTML5 and CSS3
  features without loosing control in old
  browsers
• Use declarative HTML and CSS when
  possible and fall back on procedure
  JavaScript when not
USE IT
1. Download it from modernizr.com

2. Include modernizr-1.7.min.js in your page

3. Add "no-js" class to the <html> element
WHAHOPPINED?
Google Chrome:
<html class="js flexbox canvas canvastext webgl no-
touch geolocation postmessage websqldatabase no-
indexeddb hashchange history draganddrop websockets
rgba hsla multiplebgs backgroundsize borderimage
borderradius boxshadow textshadow opacity
cssanimations csscolumns cssgradients cssreflections
csstransforms no-csstransforms3d csstransitions
fontface video audio localstorage sessionstorage
webworkers applicationcache svg inlinesvg smil
svgclippaths">
WHAHOPPINED?
FireFox:
<html class="js flexbox canvas canvastext no-webgl
no-touch geolocation postmessage no-websqldatabase
no-indexeddb hashchange no-history draganddrop no-
websockets rgba hsla multiplebgs backgroundsize
borderimage borderradius boxshadow textshadow
opacity no-cssanimations csscolumns cssgradients no-
cssreflections csstransforms no-csstransforms3d no-
csstransitions fontface video audio localstorage
sessionstorage webworkers applicationcache svg no-
inlinesvg no-smil svgclippaths">
WHAHOPPINED?
IE 8:
<html class="js no-flexbox no-canvas no-canvastext
no-webgl no-touch no-geolocation postmessage no-
websqldatabase no-indexeddb hashchange no-history
draganddrop no-websockets no-rgba no-hsla no-
multiplebgs no-backgroundsize no-borderimage no-
borderradius no-boxshadow no-textshadow no-opacity
no-cssanimations no-csscolumns no-cssgradients no-
cssreflections no-csstransforms no-csstransforms3d
no-csstransitions fontface no-video no-audio
localstorage sessionstorage no-webworkers no-
applicationcache no-svg no-inlinesvg no-smil no-
svgclippaths">
A FEW EXAMPLES...
PLACEHOLDER
var App = function(){
 var default_full_name = 'Full Name';

 return {
  init: function() {
     if(!Modernizr.input.placeholder){
       App.add_focus_events();
     }
  },

   add_focus_events: function(){
     // Set the default values
     $('#full_name').val(default_full_name);
     // Add the focus and Blur events
     $('#full_name').focus(function(){ if($(this).val()===default_full_name){ $(this).val(''); }});
     $('#full_name').blur(function(){ if($(this).val()===''){ $(this).val(default_full_name); }});
   };
  }
}();

$(document).ready(function($j){
 App.init();
});
BORDER RADIUS & BOXSHADOW
// original rule that looks nice
#content {
  border: 2px outset #666;
}

// target browsers that support border radius
// tweaking the border a little
.borderradius #content {
  border: 1px solid #141414;
  -webkit-border-radius: 12px;
  -moz-border-radius: 12px;
  border-radius: 12px;
}

// target browsers that support boxshadow
// remove the border altogether for browsers that support boxshadow
.boxshadow #content {
  border: none;
  -webkit-box-shadow: rgba(0,0,0, .5) 3px 3px 6px;
  -moz-box-shadow: rgba(0,0,0, .5) 3px 3px 6px;
  box-shadow: rgba(0,0,0, .5) 3px 3px 6px;
}                                               Example credit: Faruk Ateş - A List Apart
FONT FACE
// original rule that looks nice
h1 {
  color: #e33a89;
  font: 27px/27px Baskerville, Palatino, "Palatino Linotype",
  "Book Antiqua", Georgia, serif;
  margin: 0;
  text-shadow: #aaa 5px 5px 5px;
}

// tweak size and text shadow for browsers that support @font-face
@font-face {
  src: url(Beautiful-ES.ttf);
  font-family: "Beautiful";
}
.fontface h1 {
  font: 42px/50px Beautiful;
  text-shadow: none;
}

                                                   Example credit: Faruk Ateş - A List Apart
LEARN MORE & SOURCES
•   Modernizr (Download + Great Documentation):
    http://www.modernizr.com

•   Taking Advantage of HTML5 and CSS3 with
    Modernizr:
    http://www.alistapart.com/articles/taking-
    advantage-of-html5-and-css3-with-modernizr/

•   HTML5 Cross Browser Polyfills
    https://github.com/Modernizr/Modernizr/wiki/
    HTML5-Cross-browser-Polyfills
YOURS TRULY
Michael Enslow

Principal Developer and
Co-founder of Mister
Machine

http://mistermachine.com

Follow me: @menslow

More Related Content

PPTX
Doing More with LESS for CSS
PDF
Modern Front-End Development
PPTX
HTML5 and CSS3 Techniques You Can Use Today
PDF
Wordless, stop writing WordPress themes like it's 1998
PDF
Front-End Frameworks: a quick overview
PDF
DrupalCon Barcelona 2015
PDF
HTML 5 - Overview
PDF
Node.js & Twitter Bootstrap Crash Course
Doing More with LESS for CSS
Modern Front-End Development
HTML5 and CSS3 Techniques You Can Use Today
Wordless, stop writing WordPress themes like it's 1998
Front-End Frameworks: a quick overview
DrupalCon Barcelona 2015
HTML 5 - Overview
Node.js & Twitter Bootstrap Crash Course

What's hot (20)

PDF
Use Xdebug to profile PHP
PDF
Mastering WordPress Vol.1
PDF
Using HTML5 sensibly
PPT
Please dont touch-3.6-jsday
PDF
Multimedia on the web - HTML5 video and audio
PDF
Search in WordPress - how it works and howto customize it
PDF
How to Speed Up Your Joomla! Site
PDF
Taiwan Web Standards Talk 2011
PDF
[jqconatx] Adaptive Images for Responsive Web Design
PPTX
Bower power
PPTX
The New UI - Staying Strong with Flexbox, SASS, and {{Mustache.js}}
PDF
WordPress as the Backbone(.js)
PPTX
Blazor - An Introduction
PDF
Improving WordPress performance (xdebug and profiling)
PDF
Hidden Secrets For A Hack-Proof Joomla! Site
PDF
Bower & Grunt - A practical workflow
PPTX
HTML5 and CSS3 Techniques You Can Use Today
PPTX
Theming Wordpress for Your Showcases
PPTX
The Rich Standard: Getting Familiar with HTML5
PDF
WordCamp Finland 2015 - WordPress Security
Use Xdebug to profile PHP
Mastering WordPress Vol.1
Using HTML5 sensibly
Please dont touch-3.6-jsday
Multimedia on the web - HTML5 video and audio
Search in WordPress - how it works and howto customize it
How to Speed Up Your Joomla! Site
Taiwan Web Standards Talk 2011
[jqconatx] Adaptive Images for Responsive Web Design
Bower power
The New UI - Staying Strong with Flexbox, SASS, and {{Mustache.js}}
WordPress as the Backbone(.js)
Blazor - An Introduction
Improving WordPress performance (xdebug and profiling)
Hidden Secrets For A Hack-Proof Joomla! Site
Bower & Grunt - A practical workflow
HTML5 and CSS3 Techniques You Can Use Today
Theming Wordpress for Your Showcases
The Rich Standard: Getting Familiar with HTML5
WordCamp Finland 2015 - WordPress Security
Ad

Viewers also liked (20)

PPT
Answer to question 3 of A2 evaluation
PDF
Branding China: From Maker to Innovator
PDF
PDF
F14 101 syllabus
PDF
Exam 3 review
DOCX
El niño recreando el mundo....
PDF
Advertising Beyond Borders -Ghana
PDF
Hen 368 lecture 12 hospital market
PPTX
bada waala connect
PDF
Ch 30 the monetary system part 2
PPTX
Cyprus comenius calendars 2011
PDF
Hodges literacy and today’s technnology presentation
PPTX
მსოფლიო ქალაქები გეოურბანისტიკის საფუძვლები
PDF
DOC
P2 Spelling List Term 1
PPTX
141128 wan紹介資料
PPS
Salzburg
PDF
Millward Brown's Media Presentation - Ghana
PPTX
Evaluation 2
PPT
ITP events portfolio by Preeta Panicker
Answer to question 3 of A2 evaluation
Branding China: From Maker to Innovator
F14 101 syllabus
Exam 3 review
El niño recreando el mundo....
Advertising Beyond Borders -Ghana
Hen 368 lecture 12 hospital market
bada waala connect
Ch 30 the monetary system part 2
Cyprus comenius calendars 2011
Hodges literacy and today’s technnology presentation
მსოფლიო ქალაქები გეოურბანისტიკის საფუძვლები
P2 Spelling List Term 1
141128 wan紹介資料
Salzburg
Millward Brown's Media Presentation - Ghana
Evaluation 2
ITP events portfolio by Preeta Panicker
Ad

Similar to It's a Mod World - A Practical Guide to Rocking Modernizr (20)

PDF
Modernizr - Detecting HTML5 and CSS3 support
PDF
20111129 modernizr
PPT
Web development today
DOCX
gbar.jpgglogo.jpgmaa.jpgmaah5txt.css New Pe.docx
DOCX
modernizr-1.5.js! Modernizr JavaScript library 1.5 .docx
DOCX
jpf.jpgmodernizr-1.5.js! Modernizr JavaScript libra.docx
DOCX
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
KEY
Angels versus demons: balancing shiny and inclusive
DOCX
New Perspectives on HTML Tutorial 1 Review Assig.docx
PDF
Implementing Awesome: An HTML5/CSS3 Workshop
KEY
Intro to html5 Boilerplate
PDF
HTML5 and CSS3: does now really mean now?
KEY
Ease into HTML5 and CSS3
DOCX
Twanda.Malcolm12-6-16back.jpgTwanda.Malcolm12-6-16barchart.docx
PDF
Real solutions, no tricks
PPTX
Making HTML5 Work Everywhere
DOCX
! Modernizr v2.0.6 httpwww.modernizr.com Copyri.docx
PPT
Html5/CSS3
PDF
Practical HTML5: Using It Today
PDF
Prototyping w/HTML5 and CSS3
Modernizr - Detecting HTML5 and CSS3 support
20111129 modernizr
Web development today
gbar.jpgglogo.jpgmaa.jpgmaah5txt.css New Pe.docx
modernizr-1.5.js! Modernizr JavaScript library 1.5 .docx
jpf.jpgmodernizr-1.5.js! Modernizr JavaScript libra.docx
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
Angels versus demons: balancing shiny and inclusive
New Perspectives on HTML Tutorial 1 Review Assig.docx
Implementing Awesome: An HTML5/CSS3 Workshop
Intro to html5 Boilerplate
HTML5 and CSS3: does now really mean now?
Ease into HTML5 and CSS3
Twanda.Malcolm12-6-16back.jpgTwanda.Malcolm12-6-16barchart.docx
Real solutions, no tricks
Making HTML5 Work Everywhere
! Modernizr v2.0.6 httpwww.modernizr.com Copyri.docx
Html5/CSS3
Practical HTML5: Using It Today
Prototyping w/HTML5 and CSS3

Recently uploaded (20)

PPTX
Spectroscopy.pptx food analysis technology
PPTX
Machine Learning_overview_presentation.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Empathic Computing: Creating Shared Understanding
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PPTX
Tartificialntelligence_presentation.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Getting Started with Data Integration: FME Form 101
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
Spectroscopy.pptx food analysis technology
Machine Learning_overview_presentation.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
MIND Revenue Release Quarter 2 2025 Press Release
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Empathic Computing: Creating Shared Understanding
cloud_computing_Infrastucture_as_cloud_p
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Tartificialntelligence_presentation.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Unlocking AI with Model Context Protocol (MCP)
Getting Started with Data Integration: FME Form 101
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Building Integrated photovoltaic BIPV_UPV.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Programs and apps: productivity, graphics, security and other tools

It's a Mod World - A Practical Guide to Rocking Modernizr

  • 1. IT’S A MOD WORLD A PRACTICAL GUIDE TO ROCKING MODERNIZR
  • 2. WHAT IS IT? “Modernizr is a small and simple JavaScript library that helps you take advantage of emerging web technologies (CSS3, HTML 5).” ~from modernizr.com Tells you whether or not the current browser has HTML5 and CSS3 features natively implemented.
  • 3. THE WHO Faruk Ateş @KuraFire Paul Irish @paul_irish Alex Sexton @slexaxton
  • 4. WHERE? • http://modernizr.com • Follow: @modernizr • Contribute: https://github.com/Modernizr/Modernizr
  • 5. HOW DOES MODERNIZR WORK? • Uses feature detection to test browsers for support of HTML5 and CSS3 features • Brings an end to browser sniffing
  • 7. BROWSER SNIFF BAD ol_skool_browser_detect: function() { if(navigator.appName==='Netscape' && navigator.appVersion==='5.0 (Macintosh; en-US)'){ // Do something magical for FireFox Mac users. } } • Not reliable • Not “future-proof”
  • 8. I CAN HAZ FEATURE DETECTION? the_mod_way: function() { if(!Modernizr.input.placeholder){ // No declarative HTML5 "placeholder" support add_my_focus_event(); } } • More reliable • More “future-proof”
  • 9. USE HTML5 SEMANTIC ELEMENTS • Allows you to use semantic HTML5 elements (same as html5shim/html5shiv) • Renders block level elements as divs in non-supporting browsers • Allows you to style elements in your CSS
  • 10. MODERNIZR DOES NOT Modernizr does not add missing functionality to browsers
  • 11. UNDER THE HOOD Tests over 20 HTML5 and CSS3 features • Modernizr tries to create and do something with new features in the DOM • Browser understands: yay support! • Browser does not understand: ahhh
  • 13. PROGRESSIVE ENHANCEMENT Progressive enhancement is a strategy for web design that emphasizes accessibility, semantic HTML markup, and external stylesheet and scripting technologies. Progressive enhancement uses web technologies in a layered fashion that allows everyone to access the basic content and functionality of a web page, using any browser or Internet connection, while also providing those with better bandwidth or more advanced browser software an enhanced version of the page. ~from wikipedia • Use semantic markup • Take advantage of great stuff in the experience layer
  • 14. DO WEBSITES NEED TO LOOK THE SAME IN ALL BROWSERS?
  • 16. CONTROL • Take advantage of new HTML5 and CSS3 features without loosing control in old browsers • Use declarative HTML and CSS when possible and fall back on procedure JavaScript when not
  • 17. USE IT 1. Download it from modernizr.com 2. Include modernizr-1.7.min.js in your page 3. Add "no-js" class to the <html> element
  • 18. WHAHOPPINED? Google Chrome: <html class="js flexbox canvas canvastext webgl no- touch geolocation postmessage websqldatabase no- indexeddb hashchange history draganddrop websockets rgba hsla multiplebgs backgroundsize borderimage borderradius boxshadow textshadow opacity cssanimations csscolumns cssgradients cssreflections csstransforms no-csstransforms3d csstransitions fontface video audio localstorage sessionstorage webworkers applicationcache svg inlinesvg smil svgclippaths">
  • 19. WHAHOPPINED? FireFox: <html class="js flexbox canvas canvastext no-webgl no-touch geolocation postmessage no-websqldatabase no-indexeddb hashchange no-history draganddrop no- websockets rgba hsla multiplebgs backgroundsize borderimage borderradius boxshadow textshadow opacity no-cssanimations csscolumns cssgradients no- cssreflections csstransforms no-csstransforms3d no- csstransitions fontface video audio localstorage sessionstorage webworkers applicationcache svg no- inlinesvg no-smil svgclippaths">
  • 20. WHAHOPPINED? IE 8: <html class="js no-flexbox no-canvas no-canvastext no-webgl no-touch no-geolocation postmessage no- websqldatabase no-indexeddb hashchange no-history draganddrop no-websockets no-rgba no-hsla no- multiplebgs no-backgroundsize no-borderimage no- borderradius no-boxshadow no-textshadow no-opacity no-cssanimations no-csscolumns no-cssgradients no- cssreflections no-csstransforms no-csstransforms3d no-csstransitions fontface no-video no-audio localstorage sessionstorage no-webworkers no- applicationcache no-svg no-inlinesvg no-smil no- svgclippaths">
  • 22. PLACEHOLDER var App = function(){ var default_full_name = 'Full Name'; return { init: function() { if(!Modernizr.input.placeholder){ App.add_focus_events(); } }, add_focus_events: function(){ // Set the default values $('#full_name').val(default_full_name); // Add the focus and Blur events $('#full_name').focus(function(){ if($(this).val()===default_full_name){ $(this).val(''); }}); $('#full_name').blur(function(){ if($(this).val()===''){ $(this).val(default_full_name); }}); }; } }(); $(document).ready(function($j){ App.init(); });
  • 23. BORDER RADIUS & BOXSHADOW // original rule that looks nice #content { border: 2px outset #666; } // target browsers that support border radius // tweaking the border a little .borderradius #content { border: 1px solid #141414; -webkit-border-radius: 12px; -moz-border-radius: 12px; border-radius: 12px; } // target browsers that support boxshadow // remove the border altogether for browsers that support boxshadow .boxshadow #content { border: none; -webkit-box-shadow: rgba(0,0,0, .5) 3px 3px 6px; -moz-box-shadow: rgba(0,0,0, .5) 3px 3px 6px; box-shadow: rgba(0,0,0, .5) 3px 3px 6px; } Example credit: Faruk Ateş - A List Apart
  • 24. FONT FACE // original rule that looks nice h1 { color: #e33a89; font: 27px/27px Baskerville, Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif; margin: 0; text-shadow: #aaa 5px 5px 5px; } // tweak size and text shadow for browsers that support @font-face @font-face { src: url(Beautiful-ES.ttf); font-family: "Beautiful"; } .fontface h1 { font: 42px/50px Beautiful; text-shadow: none; } Example credit: Faruk Ateş - A List Apart
  • 25. LEARN MORE & SOURCES • Modernizr (Download + Great Documentation): http://www.modernizr.com • Taking Advantage of HTML5 and CSS3 with Modernizr: http://www.alistapart.com/articles/taking- advantage-of-html5-and-css3-with-modernizr/ • HTML5 Cross Browser Polyfills https://github.com/Modernizr/Modernizr/wiki/ HTML5-Cross-browser-Polyfills
  • 26. YOURS TRULY Michael Enslow Principal Developer and Co-founder of Mister Machine http://mistermachine.com Follow me: @menslow

Editor's Notes