Gel electrophoresis is a technique in molecular biology for determining the relative sizes of biological molecules. This is used for nucleic acids (that make DNA) and for proteins. We maintain pH in the sample to give the molecule a charge, using electricity we can draw the molecules through the gel until it settles and other techniques can be used to make these into visible representations.
Molecules migrate across the gel due to electrical charge repulsion. The smaller or light a molecule is, the further it will travel across the gel. DNA is negatively charged due to the phosphate groups in the DNA backbone, and is repelled from the negative electrode of the gel and attracted to the positive electrode. Lightweight coloured markers are used to ensure that the DNA does not run over the edge of the gel, and ladder mixtures are also used which contain molecules of known length to act as a comparison standard.