Canvas Rect
π
2026-06-14 | π HTML
## HTML Canvas `rect()` Method
The `rect()` method of the HTML Canvas 2D Context API is used to create a rectangular path.
It is important to note that the `rect()` method **does not** draw directly onto the canvas. Instead, it adds a rectangle to the current path. To actually render the rectangle on the screen, you must use the `stroke()` method (to draw the outline) or the `fill()` method (to fill the interior).
---
## Browser Support
The `rect()` method is widely supported across all modern web browsers:
* Google Chrome
* Mozilla Firefox
* Microsoft Edge / Internet Explorer 9+
* Safari
* Opera
*Note: Internet Explorer 8 and earlier versions do not support the `