Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a border on HTML5 Canvas' Text?

Tags:

People also ask

How do you add a border to canvas in HTML?

By default, a canvas has no border and no content. Note: Always specify an id attribute (to be referred to in a script), and a width and height attribute to define the size of the canvas. To add a border, use the style attribute.

How do you make a border on canvas?

Adding Borders in Canvas Canvas allows you to add borders to an image directly inside Canvas using HTML code. When editing a page with an image, click on HTML Editor in the upper corner. Inside of the HTML code of the page, look for the <img> tag and add this code inside of it, before the src= section.


I can draw text using the below code,

myCanvas.fillStyle = "Red";
myCanvas.font = "30pt Arial";
myCanvas.fillText("Some Text", 10, 30);

But I want to add a border around "Some Text", any ideas on that?