"The canvas element provides scripts with a resolution-dependent bitmap canvas, which can be used for rendering graphs, game graphics, art, or other visual images on the fly." - WHATWG spec
* The HTML5 Canvas specification clearly recommends that authors should not use the <canvas> element where they have other more suitable means available to them (i.e. for a fancy looking <header> element).
Correct
Incorrect
Default dimensions: 300x150px
<canvas width=800 height=600>
Your browser does not support canvas, sorry
</canvas><style>
canvas {
width: 800px;
height: 600px;
}
</style>
<canvas></canvas>const canvas = document.querySelector('canvas')
const context = canvas.getContext('2d') // 2d context
or
const gl = initWebGL(canvas) // WebGL context(Things are not great, but ok)
navigator.getGamepads()
Gamepad object
buttons array