Chemical bonds involve the sharing or exchange of electrons in order to fulfill the octet rule and make molecules or compounds. The octet rule states that, in order to be content, all atoms desire a filled valence shell containing eight electrons (except for elements within the first period that have one orbital that is considered full when containing two valence electrons). When dealing with main-group elements, the metals have 1-4 valence electrons while nonmetals contain 4-8. Chemical bonds are held together by electrostatic attractions.
Ionic bonds are formed between a metal and a nonmetal. It is easier for the metals to lose the few valence electrons that they have. This allows the metals to lose their exterior orbital and drop down to the one below that does fulfill the octet rule. Likewise, it is easier for the nonmetals to gain 1, 2, or 3 electrons to fill their current valence orbital.
Covalent bonds are created between two nonmetals. They share electrons in order to create a bond and fulfill the octet rule. A shared electron goes toward the octet of each of the atoms involved in the sharing.