Meet the Canvas Element
Explore how to add the HTML5 canvas element to a webpage, visualize it with CSS borders, properly size it using HTML attributes, and assign an ID for JavaScript control. This lesson sets the foundation for drawing and interacting with dynamic graphics on the web.
We'll cover the following...
The first thing we are going to do is add a canvas element to our page and make some adjustments to make them easier to work with. Before we get to any of that, you need is a blank HTML page that we will be working on. If you don’t have a blank HTML page and need some help creating one, go ahead and create a new document and add the following lines of markup into it:
Once you have a blank HTML document setup, it's time for the main event you have been eagerly waiting the past 30-ish seconds for!
Adding the Canvas Element
The canvas element is represented by the appropriately named canvas HTML tag, and it behaves just like any other HTML element you might have used in the past. To add a canvas element to your page, simply ...