At the molecular level, salt dissolves in water due to electrical charges and due to the fact that both water and salt compounds are polar, with positive and negative charges on opposite sides in the molecule. The bonds in salt compounds are called ionic because they both have an electrical charge—the chloride ion is negatively charged and the sodium ion is positively charged. Likewise, a water molecule is ionic in nature, but the bond is called covalent, with two hydrogen atoms both situating themselves with their positive charge on one side of the oxygen atom, which has a negative charge. When salt is mixed with water, the salt dissolves because the covalent bonds of water are stronger than the ionic bonds in the salt molecules.
The positively-charged side of the water molecules are attracted to the negatively-charged chloride ions and the negatively-charged side of the water molecules are attracted to the positively-charged sodium ions. Essentially, a tug-of-war ensues with the water molecules winning the match. Water molecules pull the sodium and chloride ions apart, breaking the ionic bond that held them together. After the salt compounds are pulled apart, the sodium and chloride atoms are surrounded by water molecules, as this diagram shows. Once this happens, the salt is dissolved, resulting in a homogeneous solution.