A muscle shortens because two kinds of filament slide past each other. Nothing in it gets shorter on its own. This page animates that fact from four sides: the nested levels of the tissue, the sliding itself, the swing of a single myosin head, and the calcium switch that decides whether any of it happens.
Muscle is built in six nested levels. A whole skeletal muscle, tens of centimetres long, divides into fascicles of a fraction of a millimetre, each fascicle into muscle fibres of 10 to 100 µm, each fibre into myofibrils of 1 to 2 µm, each myofibril into sarcomeres about 2 µm long, and each sarcomere into filaments 15 and 7 nm across. A muscle fibre is one cell, formed by fusion, which is why it carries many nuclei and why they sit at the rim rather than in the middle.
The sarcomere runs from one Z line to the next and is the smallest unit that contracts. Thick myosin filaments sit in the middle, thin actin filaments reach in from both Z lines, and where they overlap the muscle looks dark. Change the length and the A band, the width of the thick filament, stays 1.60 µm no matter what. Only the I band and the H zone change. That single observation is what the sliding filament theory rests on: the filaments do not shorten, they slide.
How much force a sarcomere can make depends on how far the two filaments overlap. Around 2.0 to 2.25 µm every myosin head reaches a thin filament and the tension is at its maximum. Stretch it and the overlap shrinks until there is nothing to grip. Squeeze it and the thin filaments run into each other while the thick filament hits the Z line. The length and tension curve on this page is the classic Gordon, Huxley and Julian relation, simplified.
A single myosin head goes round a cycle of five states. It binds actin while carrying ADP and phosphate. The phosphate leaves and the head swings down, still bound, dragging the thin filament about 10 nm towards the M line. ADP leaves and the head is locked on with nothing bound, which is the rigor state and is what rigor mortis fixes throughout the body. ATP binding is what releases it, and splitting that ATP cocks the head back up for the next site. ATP is therefore spent first of all on letting go, not on pulling. Several hundred pairs of heads work out of step in one sarcomere, so the filament is never dropped and the pull stays smooth.
None of this runs unless calcium says so. An action potential from the motor neuron releases acetylcholine at the neuromuscular junction, the fibre membrane depolarises, and the signal travels down the T tubules into the interior of the cell. Voltage sensors there open the release channels of the sarcoplasmic reticulum, and calcium floods the cytosol, rising from about 0.05 to 10 µM. Calcium binds troponin, tropomyosin shifts into the groove of the actin helix, and the binding sites it was covering are exposed. Only then can the heads attach.
Relaxing costs energy too. The calcium pump spends ATP to draw calcium back into the reticulum, tropomyosin slides back over the binding sites, and the muscle lets go. Shortening and relaxing both need ATP, which is why a body that has run out of it stiffens rather than going slack.