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
height="Zahl"Defines the height of the
canvasarea in CSS pixels.width="Zahl"Defines the width of the
canvasarea 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>
|
Copyright © 2010 O’Reilly Verlag GmbH & Co. KG
You may print the online version for your private use.
Otherwise, this chapter from "HTML & XHTML ─ kurz & gut" is subject to the same provisions as the printed edition: the work, including all its parts, is protected by copyright. All rights are reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
O’Reilly Verlag GmbH & Co. KG, Balthasarstraße 81, 50670 Köln, kommentar(at)oreilly.de