Met Canvas Strokerect
# HTML canvas strokeRect() Method
[ Canvas Object](#)
## Example
Draw a rectangle of 150*100 pixels:
YourbrowserdoesnotsupporttheHTML5canvastag.
JavaScriptοΌ
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.strokeRect(20,20,150,100);
[Try it Β»](#)
* * *
## Browser Support

Internet Explorer 9, Firefox, Opera, Chrome, and Safari support the strokeRect() method.
**Note:** Internet Explorer 8 and earlier versions do not support the element.
* * *
## Definition and Usage
The strokeRect() method draws a rectangle (without filling). The default stroke color is black.
**Tip:** Use the (#) property to set the stroke color, gradient, or pattern.
| JavaScript syntax: | _context_.strokeRect(_x,y,width,height_); |
| --- |
## Parameter Values
| Parameter | Description |
| --- | --- |
| _x_ | The x-coordinate of the upper-left corner of the rectangle. |
| _y_ | The y-coordinate of the upper-left corner of the rectangle. |
| _width_ | The width of the rectangle, in pixels. |
| _height_ | The height of the rectangle, in pixels. |
* * Canvas Object](#)
YouTip