O'Reilly logo

Microsoft® HTML5 Step by Step by Faithe Wempen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using the HTML5 <canvas> Tag

New in HTML5 is a tag called <canvas>, which provides a space on which you can draw graphics, run animations, and much more within a Web page. However, the <canvas> tag, by itself, doesn’t do anything. Instead, the <canvas> tag relies on JavaScript to draw the graphics it can contain. So you can see that it’s no coincidence that you’ve spent so much time learning about JavaScript in this chapter!

The <canvas> tag is one of the easiest tags in HTML5. You simply tell the browser how large you want the canvas area to be, and it creates the container accordingly. For example, The following example shows a 250 x 250 pixel <canvas>:

<canvas width="250" height="250" id="myCanvas"></canvas>

Unfortunately, as of this writing, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required