To set the stroke color of text using HTML5 Canvas, we can set the strokeStyle property of the canvas context to a color string, hex value, or RGB value, and then use the strokeText() method to stroke the text.. JavaScript. into an HTML canvas such as lines, text, images and shapes using several. stroke-width: 2em; stroke-width: 2; stroke-width: 2.5; stroke-width: 15%; Note that a unit identifier (i.e. JavaScript: var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d"); Stroke width Accessibility. JavaScript: var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d"); ctx.font = "20px Georgia"; ctx.strokeText("Hello World! The inline style The stroke-width property can accept any number, including whole numbers, decimals, and percentages: 1 stroke-width: 2px 2 stroke-width: 2em 3 stroke-width: 2 4 stroke-width: 2.5 5 stroke-width: 15% More Learn to run scripts in the browser. stroke-width="length" Attribute Values: length: Length at which we want to set the stroke-width attribute; percentage: Percentage at which we want to set the stroke-width On a zero length subpath, the stroke consists of a full circle centered at the subpath's point. The fillText () method allows you to draw a text string at a coordinate with the fill derived from the current fillStyle. The