Draw Text in Canvas in HTML5


<html>
	<head>
		<title>Draw Text in Canvas in HTML5</title>
	</head>
	<body>

		<canvas id="mycanvas" width="300" height="300" style="border: 1px solid black;"></canvas>
		<br>
		<input type="button" value="Draw Text" onclick="drawText()">

		<script type="text/javascript">

			function drawText() {
				var mycanvas = document.getElementById('mycanvas');
				var ctx = mycanvas.getContext('2d');
				ctx.fillStyle = 'red';
				ctx.font = 'bold 50px Arial';
				ctx.fillText('PMK Lab', 50, 100);
			}

		</script>

	</body>
</html>




Open site in browser and display as below: