Focus stacking (also known as focal plane merging, z-stacking or focus blending) is a digital image processing technique which combines multiple images taken at different focal distances to yield a greater depth of field (DOF) than any of the individual source images. Focus stacking can be used in any situation where individual images have an undesirably shallow depth of field; macro photography and optical microscopy are two typical examples.
To exemplify the technique, let us look at a couple photos of a spider.
At f/11 DOF is quite shallow despite the large numerical f-number.
To yield a greater DOF, we can take 8 photos at different points of focus at the same aperture of f/11. These photos are combined using focus stacking software such as Zerene Stacker, the result is a greater DOF.
There are a variety of focus stacking software to choose from. Adobe Photoshop also offers focus stacking.