Why such a small z-index (-2222)?

On some of the CSS lessons of freeCodeCamp there is a penguin drawn using divs, e.g. https://learn.freecodecamp.org/responsive-web-design/basic-css/use-css-variables-to-change-several-elements-at-once

I was just wondering, is there any specific reason for the z-index of .right-feet and .left-feet being -2222. I mean, why such large negative value, when changing it to -1 appears to have the same behaviour?


-2222 is just an arbitrary number just to make sure that the element will be really at back. In case you have an element with a -1 or -2 z-index, the element with - 2222 surely will be at the bottom. Same goes for if you want an element to be at the top no matter what, just put some big z index like 999

Yea, -1 will have the same behaviour. As a general rule, it is what @jcunanan05 says, but it’s bad practice because what happens when you need something less than that, and so on and so forth. In practice, just use -1 and if -1 is too high then -2 and so on.

1 Like