HTML 5 Canvas Vs Z-Index

Hi forum experts,

I remember playing with Z-Index in terms of placing my image at the location desired in my web-site.

Now, with HTML 5 Canvas, I wonder if Z-Index is no longer valid?

Hope to hear from you soon.

Thanks!

In Canvas you basically print pixels on top of the existing painting like paint on a… canvas :wink:

Animation is mostly frame by frame where you paint, clear, paint, clear etc…

So, z-index doesn’t make sense because there’s no such thing as layers - there’s only ever 1 layer.

Hope it helps :slight_smile:

Yes, z-index still very much has its place in CSS, and will continue to do so.

Erm…do you have an example to show you meant ? Can’t really understand putting a layer on top of another. Isn’t Z Index work the same. We put in a background colour and then we use the Z-Index to put another image on top ?

I read more into your question than I should have, see Ralph’s answer above.
The majority of websites don’t need canvas at all, it has a very small use-case.

If you do need canvas for something in the future you’ll learn that it’s just an element that you can paint pixels onto.
you can’t have multiple elements in a canvas at different z-index. There’s only ever one element the <canvas>