In this paper, a first-order projection method is used to solve the Navier–Stokes equations numerically for a time-dependent incompressible fluid inside a three-dimensional (3-D) lid-driven cavity. The flow structure in a cavity of aspect ratio δ = 1 and Reynolds numbers ( 100 , 400 , 1000 ) is compared with existing results to validate the code. We then apply the developed code to flow of a generalised Newtonian fluid with the well-known Ostwald–de Waele power-law model. Results show that, by decreasing n (further deviation from Newtonian behaviour) from 1 to 0.9, the peak values of the velocity decrease while the centre of the main vortex moves towards the upper right corner of the cavity. However, for n = 0.5 , the behaviour is reversed and the main vortex shifts back towards the centre of the cavity. We moreover demonstrate that, for the deeper cavities, δ = 2 , 4 , as the shear-thinning parameter n decreased the top-main vortex expands towards the bottom surface, and correspondingly the secondary flow becomes less pronounced in the plane perpendicular to the cavity lid.