HTML Canvas Tag | Canvas Tag | Canvas Tag in HTML5 Tutorial WDH

HTML Canvas Tag


Define :
It is used to draw graphics, on the fly, via scripting and the tag is transparent, and is only a container for graphics.

 
For Example :
Output :
                                           
 
This element will be displayed in browsers with JavaScript disabled and in browsers that do not support <canvas>.

Browser Support
Element
chrome
firefox
microsoft edge
<canvas>
4.0
2.0
9.0
 
Global and Event Attributes
This tag also supports the global and event attribute in HTML.

Example 2 :

Output :
                          
Attributes :
Attributes
value
description
height
pixels
It specifies the height of the canvas. The default value is 150
width
pixels
It specifies the height of the canvas. The default value is 150

Default CSS Settings
Most browsers will display the <canvas> element in css

canvas {
  height: 150px;
  width: 300px;
}
 
Your browser does not support html canvas tag.