HTML canvas lineWidth Property

❮ HTML canvas Reference

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);

Meaning

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


Standard Syntax

Default value:

0

JavaScript syntax:

context.lineWidth=number;



Browser Support




Status







Property Values

Value Description
number Specifies the current line width, in pixels.
❮ HTML canvas Reference