The process of gel electrophoresis uses the fact that DNA fragments are negatively charged (due to the bulky, negative phosphate groups within the sugar-phosphate backbone) in order to pull the fragments through a gel (essentially a very thick liquid). To do this, the fragments are inserted by pipette into one end of the gel slab and a positive charge is generated at the opposite end. As opposite charges attract one another, this causes the DNA fragments to move towards the other end of the gel. Importantly, as larger (i.e. longer) molecules of DNA are heavier and take up more space, the resistive forces agaisnt their movements through the gel will be greater than for the smaller fragments, so the larger frgaments will not move as far as smaller ones. In this way, the frgaments will be separated according to their size, forming 'bands' a particular distance along the gel. Using standard known lengths of DNA as a kind of ruler (known as a size standard), the length of fragments in each band of the separated DNA can be compared to the location of the bands with the known lengths of DNA, which like a ruler, will give you the size of your fragments that you are testing