Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML canvas lineWidth attribute

HTML canvas lineWidth attribute

Canvas Object Reference Canvas object

Example

Draw a rectangle using a line with a width of 10 pixels:

YourbrowserdoesnotsupporttheHTML5canvastag.

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 ExplorerFirefoxOperaGoogle ChromeSafari

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.

Canvas Object Reference Canvas object