Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Title of the document</title> </head> <body> <canvas id="exampleCanvas" width="400" height="250" style="border:1px solid #d3d3d3;"> Your browser does not support the canvas element. </canvas> <script> var canvas = document.getElementById("exampleCanvas"); var ctx = canvas.getContext("2d"); ctx.font = "40px Comic Sans MS"; ctx.fillStyle = "red"; ctx.textAlign = "center"; ctx.fillText("Canvas Text", canvas.width / 2, canvas.height / 2); </script> </body> </html>