<!DOCTYPE html>
<body>
<canvas id="canvas" width="100" height="100"></canvas>
</body>
<script>
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
var grad = ctx.createLinearGradient(0, 0, 0, 100);
grad.addColorStop(0, 'red');
grad.addColorStop(1, 'black');
ctx.fillStyle = grad;
ctx.fillRect(0, 0, 100, 100);
</script>