<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Adding Stroke to Canvas Text</title> <style> canvas { border: 8px solid blue; } </style> <script> window.onload = function() { var canvas = document.getElementById("myCanvas"); var context = canvas.getContext("2d"); context.font = "bold 30px italic"; context.textAlign = "center"; context.textBaseline = "middle"; context.strokeStyle = "green"; context.strokeText("Hello World!", 150, 40); }; </script> </head> <body> <canvas id="myCanvas" width="350" height="150"></canvas> </body> </html>