HTML5 Modernizr Tutorial

HTML5 Modernizr Tutorial



Modernizr is a small JavaScript Librarythat detects the availability of native implementations for next-generation web technologies
There are several new features which are being introduced through HTML5 and CSS3 but same time many browsers do not support these news features.
Modernizr provides an easy way to detect any new feature so that you can take corresponding action. For example, if a browser does not support video feature then you would like to display a simple page.
You can create CSS rules based on the feature availability and these rules would apply automatically on the webpage if browser does not support a new featur.
You can download latest version of this utility from Modernizr Download.

Syntax:

Before you start using Modernizr, you would have to include its javascript library in your HTML page header as follows:
<script src="modernizr.min.js" type="text/javascript"></script>
As mentioned above, you can create CSS rules based on the feature availability and these rules would apply automatically on the webpage if browser does not support a new featur.
Following is the simple syntax to handle supported and non supported features:
/* In your CSS: */
.no-audio #music {
   display: none; /* Don't show Audio options */
}
.audio #music button {
   /* Style the Play and Pause buttons nicely */
}

<!-- In your HTML: -->
<div id="music">
   <audio>
      <source src="audio.ogg" />
      <source src="audio.mp3" />
   </audio>
   <button id="play">Play</button>
   <button id="pause">Pause</button>
</div>
Here it is notable that you need to prefix "no-" to every feature/property you want to handle for the browser which does not support them.
Following is the syntax to detect a particular feature through Javascript:
if (Modernizr.audio) {
     /* properties for browsers that
     support audio */
}else{
     /* properties for browsers that
     does not support audio */
}
To learn above concept - Do Online Practice using different browsers.

Features detected by Modernizr:

Following is the list of features which can be detected by Modernizr:
FeatureCSS PropertyJavaScript Check
@font-face.fontfaceModernizr.fontface
Canvas.canvasModernizr.canvas
Canvas Text.canvastextModernizr.canvastext
HTML5 Audio.audioModernizr.audio
HTML5 Audio formatsNAModernizr.audio[format]
HTML5 Video.videoModernizr.video
HTML5 Video FormatsNAModernizr.video[format]
rgba().rgbaModernizr.rgba
hsla().hslaModernizr.hsla
border-image.borderimageModernizr.borderimage
border-radius.borderradiusModernizr.borderradius
box-shadow.boxshadowModernizr.boxshadow
Multiple backgrounds.multiplebgsModernizr.multiplebgs
opacity.opacityModernizr.opacity
CSS Animations.cssanimationsModernizr.cssanimations
CSS Columns.csscolumnsModernizr.csscolumns
CSS Gradients.cssgradientsModernizr.cssgradients
CSS Reflections.cssreflectionsModernizr.cssreflections
CSS 2D Transforms.csstransformsModernizr.csstransforms
CSS 3D Transforms.csstransforms3dModernizr.csstransforms3d
CSS Transitions.csstransitionsModernizr.csstransitions
Geolocation API.geolocationModernizr.geolocation
Input TypesNAModernizr.inputtypes[type]
Input AttributesNAModernizr.input[attribute]
localStorage.localstorageModernizr.localstorage
sessionStorage.sessionstorageModernizr.sessionstorage
Web Workers.webworkersModernizr.webworkers
applicationCache.applicationcacheModernizr.applicationcache
SVG.svgModernizr.svg
SVG Clip Paths.svgclippathsModernizr.svgclippaths
SMIL.smilModernizr.smil
Web SQL Database.websqldatabaseModernizr.websqldatabase
IndexedDB.indexeddbModernizr.indexeddb
Web Sockets.websocketsModernizr.websockets
Hashchange Event.hashchangeModernizr.hashchange
History Management.historymanagementModernizr.historymanagement
Drag and Drop.draganddropModernizr.draganddrop
Cross-window Messaging.crosswindowmessagingModernizr.crosswindowmessaging
addTest() Plugin APINAModernizr.addTest(str,fn)
HTML5 Modernizr Tutorial HTML5 Modernizr Tutorial Reviewed by Cadotz media on October 06, 2018 Rating: 5
Ndugu ahsante kwa kuitembelea Cadotz, Endelea kufurahia huduma zetu pia Tunakusogezea Cadotz uchague unachokitaka katika menyu zetu.
Bofya chini

MIZIKI | MAPENZI | AFYA