Gel electrophoresis is used to separate proteins based on charge or size and DNA based on length (Kryndushkin, Alexandrov et al. 2003). DNA is negatively charged, and is therefore placed at the end of the box with the negative electrode ensuring that when the power source is on the DNA will move towards the positive electrode and separate. The molecules are separated, by travelling through the pores at a certain speed which is relative to their size. Large molecules will pass through slower, and small molecules will pass through quickly meaning that the smaller fragments will be further down the gel in the same time period compared to the large molecules.
https://www.youtube.com/watch?v=U2-5ukpKg_Q&ebc=ANyPxKrqF1zSKSEc7HOl13XyhGIupje_GNu3X6hvKRtW-Fi7KTi1HeZJWBgZCRs1mcj2PZYBzkX0p7SiylGbO5WfnWVuDxHlaQ