HTML canvas lineWidth attribute
Example
Draw a rectangle using a line with a width of 10 pixels:
JavaScript:
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.lineWidth=10;
ctx.strokeRect(20,20,80,100);
Try it »
Browser support





Internet Explorer 9, Firefox, Opera, Chrome and Safari support the lineWidth attribute.
**Note:** Internet Explorer 8 and earlier versions do not support
Definition and Usage
The lineWidth attribute sets or returns the current line width, in pixels.
| Default value: | 1 |
|---|---|
| JavaScript syntax: | context.lineWidth=number; |
Attribute values
| Value | Description |
|---|---|
| number | The current line width, in pixels. |
HTML canvas Reference Manual