HTML canvas lineWidth attribute
Definition and Usage
lineWidth
Sets or returns the current line width in pixels.
Example
Draw a rectangle with a line width of 10 pixels:
JavaScript:
var c=document.getElementById("myCanvas"); var ctx=c.getContext("2d"); ctx.lineWidth=10; ctx.strokeRect(20,20,80,100);
Syntax
context.lineWidth=number;
Attribute Value
Value | Description |
---|---|
number | The current line width, in pixels. |
Technical Details
Default Value: | 1 |
---|
Browser Support
The numbers in the table indicate the first browser version that fully supports this property.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
4.0 | 9.0 | 3.6 | 4.0 | 10.1 |
Note:Internet Explorer 8 and earlier versions do not support the <canvas> element.