
The canvas element has no drawing abilities of its own. All drawing must be done inside a JavaScript:
JavaScript uses the id to find the canvas element:
Then, create a context object:
The getContext("2d") object is a built-in HTML5 object, with many methods to draw paths, boxes, circles, characters, images and more.
The next two lines draws a red rectangle:
The fillStyle method makes it red, and the fillRect method specifies the shape, position, and size.
Drawing in Canvas Preview