HTML canvas lineCap attribute
Example
Draw a rounded line cap:
JavaScript:
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.beginPath();
ctx.lineCap="round";
ctx.moveTo(20,20);
ctx.lineTo(20,200);
ctx.stroke();
Try it »
Browser support





Internet Explorer 9, Firefox, Opera, Chrome and Safari support the lineCap attribute.
**Note:** Internet Explorer 8 and earlier versions do not support
Definition and Usage
The lineCap attribute sets or returns the style of the cap at the end of a line.
Note:The "round" and "square" values make the line slightly longer.
| Default value: | butt |
|---|---|
| JavaScript syntax: | context.lineCap="butt|round|square"; |
Attribute values
| Value | Description |
|---|---|
| butt | Default. Adds a flat edge to each end of the line. |
| round | Adds a round cap to each end of the line. |
| square | Adds a square cap to each end of the line. |
HTML canvas Reference Manual