The canvas HTML 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.
HTML
<canvas attribute-name="attribute-value"></canvas>
Attributes
height
width
<!doctype html>
<html>
<head>
<style>
canvas
{
background-color: red;
}
</style>
</head>
<body>
<canvas width="150px">fallback content for browsers that do not support the canvas element</canvas>
</body>
</html>
CSS
<!doctype html>
<html>
<head>
<style>
canvas
{
background-color: red;
height: 300px;
width: 150px;
}
</style>
</head>
<body>
<canvas>fallback content for browsers that do not support the canvas element</canvas>
</body>
</html>
JS
<!doctype html>
<html>
<head>
<style>
canvas
{
background-color: red;
}
</style>
</head>
<body>
<canvas>fallback content for browsers that do not support the canvas element</canvas>
<script>
var style = document.querySelector("canvas").style;
style.height = "300px";
style.width = "150px";
</script>
</body>
</html>