Ionic compounds are formed when a metal and nonmetal form a bond.