HTML Canvas Example

The `` element allows you to draw graphics directly on the web page. Below is an example demonstrating how to draw a rectangle on a canvas.

Drawing on Canvas

Canvas Attributes

Here are the main attributes and properties of the `` element:

  • width: Specifies the width of the canvas in pixels. Example: width="500"
  • height: Specifies the height of the canvas in pixels. Example: height="300"

The canvas size is controlled by the width and height attributes. The canvas is styled using Tailwind CSS classes.