HTML and CSS Reference
options you may want to consider if you'd like to include Canvas apps in your EPUB,
but want to mitigate the incompatibility with other EPUB readers (e.g., Nook, Sony
Reader, Adobe Digital Editions):
• Include fallback content within your <canvas> elements that will be displayed if the
user's ereader doesn't have Canvas support (see the beginning of this chapter for
more details). This way, while readers won't be able to use the app, you can display
text, images, etc., that can potentially convey some of the same information that
would have been displayed on the Canvas.
• Instead of (or in addition to) just embedding your Canvas apps directly in the
EPUB, consider hosting them on the Web and linking to them from your EPUB,
so that readers can access them from a traditional Desktop or mobile web browser.
Many modern hardware ereaders (again, iBooks, but also the Nook Color) have
built-in web browsers, so even if the ereader software itself doesn't support can
vas , the web browser may. Additionally, readers viewing your EPUB on a desktop/
laptop machine (say, in Adobe Digital Editions) can click on your link and run the
Canvas app in Firefox or Chrome. The one downside of this approach is that read-
ers will obviously still need Internet access in order to access the app.
Testing for HTML5 Compatibility with Modernizr
You may have noticed that the preceding <canvas> examples in this chapter included
a script called modernizr-1.6.min.js in the HTML:
compatibility with HTML5 and CSS3 features. Specifically, it provides the following
functions for testing the features covered in this topic:
Tests for HTML5 Canvas support
Tests for Geolocation API support
Tests for HTML5 audio support. It can also test specifically for support
for .m4a , .mp3 , .ogg , and .wav file formats.
Tests for HTML5 video support. It can also test specifically for support for H.
264 .mp4 , .ogg , and .webm file formats.
It's good practice to use a library like Modernizr to do compatibility testing for HTML5
browser does not have support for the requisite HTML5 elements. However, note that
ebook content, don't rely solely on Modernizr to provide your fallbacks. Your best bet