Magnet
Rare earth (lanthanoid) elements have a partially occupied "f" electron shell (which can accommodate up to 14 electrons). The spin of these electrons can be aligned, resulting in very strong magnetic fields, and therefore, these elements are used in compact high-strength magnets where their higher price is not a concern. The most common types of rare-earth magnets are samarium-cobalt and neodymium-iron-boron (NIB) magnets.
Magnetic alloy
A magnetic alloy is a combination of various metals from the periodic table such as ferrite that contains at least one of the three main magnetic elements: iron (Fe), nickel (Ni), or cobalt (Co) etc.. Such an alloy must contain but is not limited to one or more of these metals. Magnetic alloys have become common, especially in the form of steel (iron and carbon), alnico (iron, nickel, cobalt, and aluminum), and permalloy (iron and nickel). The strongest magnetic element is iron, which allows items made out of these alloys to attract to magnets.