DNA fragments created by restriction enzymes are separated based on their rate of movement through a gel in an electric field.
How far a DNA molecule travels is inversely proportional to its length.
After the current is turned off, a dye is added; this reveals the separated bands by fluorescing in ultraviolet light.