HTML and CSS Reference
In-Depth Information
and audio formats and encode them in a variety of different formats. It provides
a large set of presets for different video delivery situations.
Last but not least
The new canvas element is used to embed a scriptable bitmap into the web page.
This essentially means the capability now exists to place a blank image on the page
of a certain dimension, which can be drawn upon and graphically manipulated from
JavaScript code. Cool! The element itself it quite basic; it just defines two attributes,
width and height , for specifying the dimensions of the canvas. Like prior elements
in this chapter, it contains the ability to provide fallback content through placing addi-
tional HTML between its opening and closing tags, like so:
<canvas width="600" height="300">
<p>The canvas element is not supported!</p>
</canvas>
Like other elements, more fallback content than text could be placed in between the
opening and closing tags, but canvas is pretty unique, so it may be hard to find suitable
alternative content beyond text. Flash could be used as a replacement, so you could, for
example, build an interactive application using canvas and replicate that functionality
in Flash to provide as fallback content. The object element (or more rarely, the em-
bed element) would then be used inside canvas . At any rate, if you tried the previous
code on a page, it wouldn't be very exciting because it would just create a blank area
in the page layout that was 600 by 300 pixels wide and tall. The real power of canvas
comes from dynamically generating imagery using JavaScript, which we will get into in
Chapter 7 .
Summary
As you have seen, HTML5 has made it easier to include multimedia in your web pages.
The semantics are improved too because there are elements dedicated to images, video,
and sound, instead of so many types of media relying on a generic object element
as has been the case in the past (at least as far as video and audio are concerned). To
handle the transition toward richer media in web pages, the new elements (and some
of the old) include a consistent and intuitive fallback mechanism. object , iframe ,
video , audio , canvas , and perhaps soon track all provide the same mechanism
for handling alternative content. There is more to look forward to as the specification
for timed text moves forward and browsers implement missing features. Perhaps one
Search WWH ::




Custom Search