Scientists in labs use a technique called gel electrophoresis which allows them to separate a mix of DNA fragments by size.
This is used in conjunction with PCR (polymerase chain reaction) and restriction digests (digesting DNA with enzymes) to see what products are created in the reaction.
In gel electrophoresis, a rectangular jelly is made from a sugar called agarose and water. The jelly is immersed in a buffer (salt solution). The samples are loaded in a row at one end of jelly. An electric current is applied, with the negative terminal at the end of the jelly the samples were loaded.
DNA has a negative charge, due to the electron dense phosphate backbone. This means it moves away from the negative terminal and towards the positive terminal. However, the jelly impedes the movement of larger fragments, and as a result fragments will travel through the jelly according to their size. This separates out the fragments.
Once the fragments have been separated, the jelly is removed and stained in a solution containing ethidium bromide. Ethidium bromide is a flat, ringed molecule that can sit between the base pairs in the DNA ladder- it can intercalate DNA. Ethidium bromide absorbs UV light. This means that DNA in the jelly can be visualised under a UV light after it has been stained with ethidium bromide.