Graphics and Animation

1. The ''<canvas>'' Element

Draw graphics using JavaScript:

<canvas id="myCanvas" width="400" height="200"></canvas>
<script>
    var canvas = document.getElementById("myCanvas");
    var ctx = canvas.getContext("2d");
    ctx.fillStyle = "red";
    ctx.fillRect(20, 20, 150, 100);
</script>

2. Scalable Vector Graphics (SVG)

SVG enables defining vector graphics:

<svg width="100" height="100">
    <circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
</svg>