Gel electrophoresis separates molecules like DNA based on their charge and size. DNA fragments are placed in an agar gel and an electric current is applied, causing the fragments to migrate through the gel at different rates according to their size. Smaller fragments move farther than larger ones. This allows DNA fragments to be sorted and visualized on the basis of length.