Advertisement
Home Open Editor ❯

HTML canvas lineWidth Property

Example

// Accessing the element
let c = document.getElementById("myCanvas");

// Styling canvas
let ctx = c.getContext("2d");
ctx.lineWidth = 5;
ctx.strokeRect(25, 25, 100, 100);

Try this code ❯

Meaning

The lineWidth canvas property sets or returns the current line width.


Standard Syntax

Default value:

0

JavaScript syntax:

context.lineWidth=number;


Advertisement

Property Values

Value Description
number Specifies the current line width, in pixels.
Home Open Editor ❯
Advertisement