A molecule is a group of atoms that are chemically bonded together. The chemical bonds consist of pairs of electrons that are shared between two atoms. A molecule is electrically neutral, meaning that the total number of protons and electrons are equal so no electrons have been lost or gained.
Molecules are usally produced by the reaction of two or more different chemical elements. However, some elements exist as molecules of like atoms. For example, oxygen gas is `O_2` and hydrogen gas is `H_2` . These are called diatomic molecules. The other diatomic elements are nitrogen, fluorine, chlorine, bromine and iodine.
Some compounds exist as discrete covalently bonded molecules, for example `H_2O` and `CO_2` , but others don't. Ionic compounds exist as large numbers of repeating ions in a three dimensional structure called a crystal lattice. The formula NaCl for sodium chloride tells us that the ratio of sodium ions to chloride ions is 1:1, but it's not made up of separate NaCl moleucules.