When atoms share electrons, they create a covalent bond. This is the strongest type of chemical bond, and it is found in molecules like water and carbon dioxide.
When atoms transfer electrons, they create an ionic bond. This type of bond is weaker than a covalent bond, and it is found in molecules like sodium chloride.