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 ...
No credit card required