How it works
The shelf is treated as resting on a support at each end (shelf pins, bearers or a housing), with its load and its own weight spread evenly along it. It sags in the middle by five times the load per length times the span to the fourth power, over 384 times the board's stiffness: a shelf twice as long sags sixteen times as much, and one twice as thick, an eighth as much.
Under a load that stays on, boards keep slowly bending (they creep). The later figure allows for that, with the factors Eurocode 5 gives for indoor use: MDF and chipboard about three times the first sag, plywood a little under twice, solid timber about one and a half times. The verdict goes by the later figure.
A hardwood strip on the front edge stands on edge, where wood is stiffest, so it stiffens the shelf far more than its size suggests. The sums treat it as oak, glued on with its top level with the shelf's.
Questions
How far can an 18 mm MDF shelf span?
Full of hardback books and 250 mm deep, only about 350 mm before the sag shows in time, because MDF creeps under a load that stays on. With an oak strip 40 × 20 mm glued along its front edge, about 740 mm. Birch plywood the same size manages about 570 mm, and pine about 630 mm.
Why does it sag more after a year or two?
Boards and timber creep: under a load that never comes off, they slowly bend further. MDF and chipboard creep the most, about three times the first sag over time; solid timber about one and a half times. The figures come from Eurocode 5's factors for indoors.
How much sag is too much?
A common rule is a 600th of the span: 1.3 mm on an 800 mm shelf, which nobody will notice. Up to a 300th you might see it against a straight line, like the shelf above. Beyond that it looks bent.
What stops a shelf sagging?
A shorter span, a thicker or stiffer board, a hardwood strip glued along the front edge (it works far better than you'd think, as it stands on edge), or fixing the shelf to a batten along the back so only the front can move.
How accurate is it?
It's an estimate, for a shelf resting on a support at each end with its load spread along it. Boards vary from one maker to the next, and a shelf housed into its ends or fixed along its back sags less than this says.