There are two main types of compounds: ionic compounds and binary molecular compounds. Ionic compounds form when a metal transfers electrons to a non-metal, creating oppositely charged ions held together by electrostatic attraction. Binary molecular compounds form when two non-metals share electrons in a covalent bond to achieve a full outer shell of 8 electrons. Examples of ionic compounds include LiF, formed when the metal Li loses an electron to the non-metal F. Examples of binary molecular compounds include CH4 and CO2, with covalent bonds between the non-metals.