Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

HTML <canvas> tags


May 04, 2021 HTML Reference Manual


Table of contents


HTML slt;canvas.gt; tags

The label is a newly defined label in HTML5, it is a canvas label, just as a graphic container, you must use a script to draw the drawing.

A red rectangle is displayed by the element of the .

<canvas id="myCanvas"></canvas>

<script type="text/javascript">
var canvas=document.getElementById('myCanvas');
var ctx=canvas.getContext('2d');
ctx.fillStyle='#FF0000';
ctx.fillRect(0,0,80,100);
</script>

Try it out . . .

Browser support

HTML <canvas> tags HTML <canvas> tags HTML <canvas> tags HTML <canvas> tags HTML <canvas> tags

IE 9, Firefox, Opera, Chrome, and Safari support the hashtags.

Note: IE 8 or earlier versions of IE browsers do not support the hashtag.

Tip: We can place a piece of text between the start and end labels of the label, which will appear on the location of the label when the browser does not support the label, and the user will understand that the label does not apply to this browser.


Label definition and instructions for use

Labels are scripted (usually JavaScript) to draw graphs (such as charts and other images).

The label is just a graphics container, and you must use a script to draw the drawing.


The difference between HTML 4.01 and HTML5

The label is the new label in HTML5.


Tips and comments

Note: Any text in the element will be displayed in browsers that do not support the .lt;canvas.

Tip: For all the properties and methods of canvas objects, see the HTML Canvas Reference Manual.


Property

New : The new property in HTML5.

Attributes value describe
height New pixels Specify the height of the canvas.
width New pixels Specifies the width of the canvas.

Global properties

The label supports the global properties of HTML.


The event property

The tag supports the event properties of HTML.

Related articles

HTML DOM Canvas object