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.
<!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*/