In the previous section, we basically defined our canvas element in markup. While important, what we’ve just done is a very VERY minor part of working with the canvas overall. The real work is about to happen in this section when we write the JavaScript that interacts with the canvas element to get pixels to show up on the screen.

Adding the Script Tags

Before we can write JavaScript, we need a script tag that will house the JavaScript we write. You can use an external JavaScript file or keep all of the code in the same document. It will look something as follows:

Get hands-on with 1400+ tech skills courses.