HTML and CSS Reference
In-Depth Information
We could write something more sophisticated, but the message is the message, so let's leave
well enough alone. If you've got an HTML5 browser, everything is Jake. If not, the user i nds
out why not in a message. (You may want to i ne-tune the message for your audience — from
Jane Austen to Ivan the Terrible.)
Before we get rolling on creating your own drawings, let's look at one more way that you can
keep out of hot water with non-HTML5 users. In addition to adding text, you can add photos
or anything else in the <canvas> container. For example, the following script ( Canvas-
Photo.html in this chapter's folder at ) provides
an alternative to a more sophisticated presentation of a photo image using canvas .
< html >
< head >
< style type = ”text/css” >
body {
font-family:Verdana, Geneva, sans-serif;
img {
</ style >
< meta http-equiv = ”Content-Type” content = ”text/html; charset=UTF-8” >
< title > Fisherkid </ title >
</ head >
< body >
< body onLoad = ”CanvasMaster.showCanvas()” >
<canvas id = ”photo” width = ”300” height = ”272” > Gentle viewer, if you see this message,
that means (alas) you don't have an HTML5 browser. (But you can see the photo and
caption.) < br >
<figure> < img src = ”fisherkid.jpg” width = ”300” height = ”272” alt = ”kid fishing” />< br >
<figcaption> Kid Fishing </figcaption>
</ body >
</ html >
Not only will the non-HTML5 viewer get the message about updating his browser, but he'll
get it in the style described in CSS3. He'll also be able to view both the picture and the
caption, as shown in Figure 13-3.
If you do use an HTML5 browser, the preceding program presents a big blank green screen
with nothing on it. So, be sure that if you're using an alternative for non-HTML5 browsers,
you have something actually in canvas .
Search WWH ::

Custom Search