In an electrical field, samples containing different size DNA fragmentswill migrate through a gel containing pores of fixed sizes.
This is done using the charge properties of DNA. DNA in gel is visualized with a UV-visible dye.