The canvas element is a bitmap drawing API, and once you’ve committed to a set of pixels, you’re stuck with them.
The canvas element is good for pixel manipulation and highly active animations.
SVG is the alternative drawing API.
It’s vector-based and does support layers.
SVG also exists in the DOM, making it easy to attach event handlers for interactivity, and it’s easier to deal with collision detection (in games, for example).
It also supports animation either through SMIL or JavaScript.
There’s an excellent JavaScript library called Raphaël that uses SVG to render images and animations.
Very cool but hard to program. Fun demos below:
It’s possible to use all 3 drawing styles on a single web page.
Is it possible to draw a 3D canvas onto a 2D canvas or vice versa?