The molecules to be separated are pushed by an electrical field through a gel containing small pores. The molecules travel through these pores in the gel at a speed which is inversely related. This means that a small molecule will travel a greater distance through the gel than will a larger molecule. One end of the gel has a positive charge and the other end has a negative charge.
Structurally, DNA and RNA are negatively charged molecules, so they will be pulled toward the positively charged end of the gel. In the case of proteins, they are not purely negatively charged, so first proteins are mix with an anionic detergent called sodium dodecyl sulfate. This treatment makes the proteins unfold into a linear shape and coats them with a negative charge, which allows them to migrate toward the positive end of the gel and be separated.
Steps of gel electrophoresis:
When DNA, RNA and protein molecules have been separated using gel electrophoresis, bands of different sizes can be detected by UV illuminator.