XML technologies / HTML & XHTML / Alphabetical list of HTML and XHTML elements / canvas

(Excerpt from "HTML & XHTML ─ kurz & gut" by Jennifer Niederst Robbins)

A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

   

HTML 5

canvas

<canvas> ... </canvas>

Represents a two-dimensional area for displaying dynamic bitmap graphics, such as charts or games. The image on the canvas is generated by scripts.

Notes

HTML 5 only.

The canvas element is among the HTML 5 elements already fairly well supported by browsers. Basic support is available in Firefox 2.0+, Safari 3.1+, Chrome 1.0+ and Opera 9.0+, for example. Support has already been announced for Internet Explorer 9. In the meantime, developers can use the ExplorerCanvas workaround. A working group is examining ways to improve accessibility for canvas.

Start/end tag

Required/required

Attributes

Global HTML 5 attributes

  • height="Zahl"

    Defines the height of the canvas area in CSS pixels.

  • width="Zahl"

    Defines the width of the canvas area in CSS pixels.

Example

<html>
<head>
  <script type="application/x-javascript">
function draw() {
 var canvas = document.getElementById("box");
 var ctx = canvas.getContext("2d");
 ctx.fillStyle = "rgb(163, 120, 240)";
 ctx.fillRect (55, 50, 75, 100);
}
  </script>
</head>
<body onload="draw()">
  <canvas id="box" width="250" height="250"></canvas>
</body>
</html>

 

> back to the alphabetical list of elements

   

 

 

 

back to top