While atoms of an element do exist alone, they often combine with other atoms to form compounds, the smallest quantity of which is referred to as a molecule. These molecules can be formed through either ionic, metallic, covalent or hydrogen bonding.
Ionic bonding occurs when atoms either gain or lose one or more valence electrons, resulting in the atom having either a negative or positive charge. Elements such as sodium that have almost empty outer shells, will usually react with atoms like chlorine that have almost full outer shells. When a sodium atom loses an electron, its charge becomes a +1; when a chlorine atom gains an electron, its charge becomes a -1. Through ionic bonding, an atom of each element will combine with the other to form a molecule, which is more stable since it now has a zero charge. In general, ionic bonding results in a complete transfer of electrons from one atom to another.
Instead of losing or gaining electrons, some atoms instead share electrons when they form molecules. Atoms that form bonds by this method, called covalent bonding, are usually non-metals. By sharing electrons, the resulting molecules are more stable than their previous components were, since this bond allows each atom to fulfill its electron requirements; that is, the electrons are attracted to the nuclei of each atom. Atoms of the same element can form single, double or triple covalent bonds, depending on the number of valence electrons they contain.
Metallic bonding is a third type of bonding that occurs between atoms. As its name implies, this type of bond occurs between metals. In metallic bonding, many atoms share valence electrons; this occurs because individual atoms only loosely hold their electrons. It is this ability of electrons to move freely between numerous atoms that gives metals their distinctive qualities, such as malleability and conductivity. This ability to bend or be shaped without breaking occurs because the electrons simply slide over each other instead of separating. The ability for metals to conduct electricity also occurs because these shared electrons readily pass between atoms.
While ionic, covalent and metallic bonding are the main types of bonding used to form compounds and give them their unique qualities, hydrogen bonding is a very specialized type of bonding that only occurs between hydrogen and oxygen, nitrogen or fluorine. Since these atoms are much larger than a hydrogen atom, the electrons will tend to stay closer to the larger atom, giving it a slightly negative charge and the hydrogen atom a slightly positive charge. It is this polarity that allows water molecules to stick together; this polarity also allows water to dissolve many other compounds.
Some atoms can form more than one type of bond; for example, metals such as magnesium can form either ionic or metallic bonds, depending on whether the other atom is a metal or non-metal. The result of all bonding, however, is a stable compound with a unique set of properties.