O'Reilly logo

HTML5 and CSS3 Transition, Transformation, and Animation by Gianluca Guarini, Aravind Shenoy

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

Canvas

The canvas element is one of the awesome features of HTML5. It enables us to draw graphics within the defined boundaries. Though canvas is an HTML element, it works in tandem with the JavaScript API. Let's look at how the canvas element is defined in HTML5 as follows:

<canvas id = "demo" width = "500" height = "150"> </canvas>

The id attribute is optional, but very useful as it is extensively used in HTML5. The width and height attributes of the canvas element have to be defined to understand the boundaries of the canvas element. If the height and width attributes are not defined, then the default value is considered that is the width attribute would be 300 pixels and height would be 150 pixels by default. However, it is a good practice to ...

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