Canvas Hello World

The <canvas> element represents a surface upon which you can draw things.

If your browser supports the <canvas> element, then you should see the Hello World! above in an outline style. The canvas element is declared with simply the width and height attribute:

<canvas id="myCanvas" width="200" height="30"/>

The script to do the drawing gets a 2D drawing context for myCanvas, configures the font, and then calls strokeText.

var context = myCanvas.getContext("2d"); context.font = "30px sans-serif"; context.strokeText("Hello World!", 20, 25);