The technique is called Gel Electrophoresis. DNA is negatively charged, forced to move towards the anode, electric field agarose gel matrix, separated according to their size/sieving effect, smaller fragments move faster and further than the larger. They can be separated by forcing them to move towards the anode under an electric field through a medium/matrix.