<!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <script type="application/javascript"> function draw() { var canvas = document.getElementById('canvas'); if (canvas.getContext) { var ctx = canvas.getContext('2d'); ctx.fillStyle ='red'; ctx.fillRect(95, 100,200, 100); ctx.beginPath(); ctx.fillStyle='#000' ctx.moveTo(200, 20); ctx.lineTo(90, 100); ctx.lineTo(300, 100); ctx.fill(); } } </script> <style type="text/css"> canvas { border: 1px solid black; } </style> </head> <body onload="draw();"> <canvas id="canvas" width="300" height="300" ></canvas> </body> </html>