Seal the edges and apply primer on both sides of the surface before painting MDF. This is a porous material that absorbs fluids quickly and produces uneven results without priming. Use protective goggles and a mask to sand the MDF. Use a sanding block to create even surfaces.
MDF contains formaldehyde and other toxic compounds. Priming MDF seals the wood fibers, preventing the release of hazardous compounds into the air and smoothing out the surface to create an even paint coat. The edges are more porous than the face and back surfaces. Use drywall compound or wood filler to seal the edges and even out with a scrapper. Sand the MDF with 120 grit sandpaper to remove dirt. Dust off the MDF with a brush. Sand the edges to remove the excess sealing material. Use 220 grit silicon-carbide sandpaper to even out edges shaped with a router.
MDF swells and becomes deformed with water. Avoid water-based primers and choose a solvent-based or oil-based primer. Apply a layer of primer to the surfaces and the edges. Prime the back surface to protect the MDF against accidental water spills that roll down the edges and reach the back. Gently sand the primer coat and remove the dust. Before applying a second coat of primer, wipe down the surfaces with a rag lightly dipped in white spirits to remove any residual grease. Apply a second layer of primer, let it dry and sand lightly. Then, apply the desired paint color.