We have used viscous fluids in simple laboratory experiments to explore the dynamics of grounding lines between marine ice sheets and the freely floating ice shelves into which they develop. We model the ice sheets as shear-dominated gravity currents, and the ice shelves as extensional gravity currents having zero shear to leading order. We consider the flow of viscous fluid down an inclined plane into a dense inviscid ‘ocean’. A fixed flux of fluid is supplied at the top of the plane, which is at ‘sea level’. The fluid forms a gravity current flowing down and attached to the plane for some distance before detaching to form a freely floating extensional current. We have derived a mathematical model of the flow that incorporates a new dynamic boundary condition for the position of the grounding line, where the gravity current loses contact with the solid base. The grounding line initially advances and eventually reaches a steady position. Good agreement between our theoretical predictions and experimental measurements and observations gives confidence in the fundamental assumptions of our model.