HTML5 Game - Using the canvas element with basic fallback content

Introduction

The width and height attributes specify the size of the element on screen.

I applied a style to the canvas element in this example to set a border.

Otherwise there would be no way to see the canvas in the browser window.

Demo

ResultView the demo in separate window

<!DOCTYPE HTML>  
<html>  
    <head>  
        <title>Example</title>  
        <style>  
            canvas {border: medium double black; margin: 4px}  
        </style>  
    </head>  
    <body>  
        <canvas width="500" height="200">  
            Your browser doesn't support the <code>canvas</code> element  
        </canvas>  
    </body>  
</html>/*from  w ww .j a v  a2 s  .  co m*/

Related Topic