The term z-order refers to the order in which objects are drawn on top of each other. An object on top in the z-order may obscure those below it, if they overlap and if the top object is not transparent. The term z-order derives from the notion of the third coordinate axis, Z, which is imagined to extend perpendicular to the X/Y plane of the drawing toward the viewer. Objects higher in the z-order are thus “closer” to the viewer.
Objects you create are always placed at the very top of the z-order of the current layer (and if you didn’t create any new layers, this will be the top of the z-order of the entire document). For example, if you draw several ellipses, each new one will be drawn on top of the previous ones, as shown in Figure 4-4.
In the SVG source of the document, objects that are higher in z-order are those that are closer to the end of the document. Thus, new objects are always added to the end of the list of existing elements (usually within the current layer).
No selecting, transforming, or style changing operations change the z-order of objects. This means you can move, scale, or paint an object while it remains upon its own “floor”—provided you’ve selected that object. (In 5.9 Selecting Objects from Underneath, you’ll see that special methods exist for selecting objects that are at the bottom of the z-order and cannot be simply clicked to select.)
Quite often, however, you need to rearrange the stack of objects in your drawing. Inkscape has four commands for moving objects up or down in z-order, two absolute ones and two relative. They are used regularly, so they can be accessed via buttons on the Selector controls bar, via the Object menu, or via simple keyboard shortcuts. The absolute commands are:
Raises selected objects to the very top of the objects’ layer.
Lowers selected objects to the very bottom of the objects’ layer.
The relative commands are:
Raises selected objects up one step (past one other object).
Lowers selected objects down one step (past one other object).
Figure 4-5 shows an example of how these commands work on the selected ellipse that is in the middle of a stack of rectangles.
Note that the relative z-order commands take into account only those objects that overlap the selection (more precisely, those objects whose bounding boxes overlap the bounding box of the selection). If your selected object or objects do not overlap any others, the Raise and Lower commands will just move the selection all the way to the top or bottom of the layer, correspondingly.
Another important thing to remember is that all z-order commands work only within the layer. If you have several layers in your document, these layers form their own z-order, and an object in a lower layer can never be on top of an object in a layer above. For rearranging the z-order of layers, use layer commands as described in 4.6.2 The Layer Menu.
It is possible to have objects in different layers or groups selected at the same time. In this case, the z-order commands work on each selected object within its own layer or group. For example, it may be that a Raise to Top command will change the z-order of one selected object but will leave the other untouched if it was already the topmost object in its layer.