HTML Canvas
Draw graphics using canvas with JavaScript.
David Miller
December 15, 2025
4.5k129
Canvas is used to draw shapes and animations.
## Why canvas exists
- charts
- games
- drawings
## Example
```html
<canvas id="box" width="200" height="100"></canvas>
<script>
const c = document.getElementById("box");
const ctx = c.getContext("2d");
ctx.fillStyle = "blue";
ctx.fillRect(10,10,150,50);
</script>
```
## UI Preview
A blue rectangle appears.
## Note
Canvas needs JavaScript to work.
#HTML#Graphics