The periodic table is a catalogue of all the known elements, and it's safe to say that this universe wouldn't exist if these elements didn't combine. Each element is characterized by an atom with a certain number of protons and neutrons in its nucleus and a certain number of electrons surrounding them. When atoms combine, they share their outermost electrons to create more sustainable energy states. This sharing bonds the atoms into an ionic structure or a molecule.
TL;DR (Too Long; Didn't Read)
Atoms can combine into ionic lattice structures or into covalent molecules. When different types of atoms combine, the result is called a compound.
How Atoms Combine
The propensity for an atom to combine depends on the number of electrons it has in its outer shell. Every shell has eight spaces for electrons except the first shell, which has only two spaces. If a few of the spaces aren't occupied, an atom seeks to acquire or share electrons to fill it to achieve a stable outer shell with eight electrons. On the other hand, it's easier for an atom with just a few extra electrons to get rid of them to achieve stability. The noble gases, which include helium, argon and neon, already have stable outer shells filled with electrons, so these elements do not form combinations with each other or with other atoms.
Ionic Compound: An atom with only one electron in its outer shell seeks to donate the electron to another atom, while one with a single space will readily accept it. The atom that donates this electron becomes positively charged as a result, and the atom that accepts it becomes negatively charged. Electrostatic attraction then bonds the atoms into a lattice structure. This isn't a molecule, because the pairs of atoms aren't independent, but it's a compound, because it's formed from two different elements. Common table salt, sodium chloride (NaCl), is the classic example of an ionic compound.
Covalent Bonding: An atom with one, two, three or four extra electrons in its outer shell, or one missing one, two or three electrons, seeks to share electrons to achieve stability. When this sharing happens in pairs, the bond is called a covalent bond, and it can be very strong. The water molecule, which is formed when an oxygen molecule fills its outer shells with electrons from two hydrogen atoms, is an example. Atoms can share one, two or three electron pairs, and the compounds they form tend to have lower melting and boiling points than ionic compounds.
All elements except metals form covalent bonds. Part of what makes a metal what it is is its propensity to lose the electrons in its outer shell and become an ion, which is a charged particle. Ions prefer to coalesce into solid lattice structures. Covalent molecules, on the other hand, more often form liquids or gases.
When Is a Molecule a Compound?
Atoms can combine to form simple molecules, such as water, or they can combine in large strings to form complex ones, such as sucrose (C12H22O11). Because carbon has four electrons in its outer shell, it donates and accepts electrons equally well, and it's the building block of all organic molecules on which life depends. All inorganic and organic molecules composed of more than one element are compounds. Examples are hydrogen chloride (HCl), methane (CH4), carbon dioxide (CO2) and sucrose.
It's also common for atoms of the same element to share electrons to achieve stability. The two most abundant gases in the atmosphere, nitrogen (N2) and oxygen (O2), are composed of molecules formed from a single element. Nitrogen and oxygen molecules are not compounds, because they are not composed of different elements. Even ozone (O3), a less stable and more reactive combination of oxygen molecules, fails to qualify as a compound, because it consists of only a single element.