Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Setting Canvas Text Color and Alignment</title> <style> canvas { border: 1px solid #000; } </style> <script> window.onload = function() { var canvas = document.getElementById("myCanvas"); var context = canvas.getContext("2d"); context.font = "bold 32px Arial"; context.textAlign = "center"; context.textBaseline = "middle"; context.fillStyle = "orange"; context.fillText("Hello World!", 150, 100); }; </script> </head> <body> <canvas id="myCanvas" width="300" height="200"></canvas> </body> </html>