Gel electrophoresis of nucleic acids is an analytical technique to separate DNA or RNA fragments by size and reactivity. Nucleic acid molecules are placed on a gel, where an electric field induces the nucleic acids (which are negatively charged due to their sugar-phosphate backbone) to migrate toward the positively charged anode. The molecules separate as they travel through the gel based on the each molecule's size and shape. Longer molecules move more slowly because they the gel resists their movement more forcefully than it resists shorter molecules. After some time, the electricity is turned off and the positions of the different molecules are analyzed.
The nucleic acid to be separated can be prepared in several ways before separation by electrophoresis. In the case of large DNA molecules, the DNA is frequently cut into smaller fragments using a DNA restriction endonuclease (or restriction enzyme). In other instances, such as PCR amplified samples, enzymes present in the sample that might affect the separation of the molecules are removed through various means before analysis. Once the nucleic acid is properly prepared, the samples of the nucleic acid solution are placed in the wells of the gel and a voltage is applied across the gel for a specified amount of time.
The DNA fragments of different lengths are visualized using a fluorescent dye specific for DNA, such as ethidium bromide. The gel shows bands corresponding to different nucleic acid molecules populations with different molecular weight.  Fragment size is usually reported in "nucleotides", "base pairs" or "kb" (for thousands of base pairs) depending upon whether single- or double-stranded nucleic acid has been separated. Fragment size determination is typically done by comparison to commercially available DNA markers containing linear DNA fragments of known length.
The types of gel most commonly used for nucleic acid electrophoresis are agarose (for relatively long DNA molecules) and polyacrylamide (for high resolution of short DNA molecules, for example in DNA sequencing).  Gels have conventionally been run in a "slab" format such as that shown in the figure, but capillary electrophoresis has become important for applications such as high-throughput DNA sequencing.  Electrophoresis techniques used in the assessment of DNA damage include alkaline gel electrophoresis and pulsed field gel electrophoresis.
For short DNA segments such as 20 to 60 bp double stranded DNA, running them in polyacrylamide gel (PAGE) will give better resolution (native condition). Similarly, RNA and single-stranded DNA can be run and visualised by PAGE gels containing denaturing agents such as urea. PAGE gels are widely used in techniques such as DNA foot printing, EMSA and other DNA-protein interaction techniques.
The measurement and analysis are mostly done with a specialized gel analysis software.  Capillary electrophoresis results are typically displayed in a trace view called an electropherogram.