We all know that magnets attract metals like iron, nickel and cobalt. They are made from metals or alloys that determine the strength of the magnets.
Magnets produce magnetic fields and the magnetic field's lines of force exit the magnet from its north pole and enter its south pole. Permanent or hard magnets create their own magnetic field all the time. Temporary or soft magnets produce magnetic fields while in the presence of a magnetic field and for a short while after exiting the field. Electromagnets produce magnetic fields only when electricity travels through their wire coils.
Neodymium is a rare earth element. The magnet which is made from an alloy of Neodymium, iron and boron (NdFeB) are neodymium magnets. These are the strongest type of magnets available today. Ceramic magnets, like the ones used in refrigerator magnets and elementary-school science experiments, contain iron oxide in a ceramic composite. These magnets are also called ferric magnets and they aren't very strong.
There are microscopic regions called magnetic domains in the physical structure of ferromagnetic materials like iron, cobalt and nickel. Each domain further acts as a tiny magnet with north and south pole. In an unmagnetized ferromagnetic material, each of the north poles points in a random direction. Magnetic domains oriented in opposite directions cancel one another out and the material does not produce a net magnetic field. In magnets, on the other hand, most or all of the magnetic domains point in the same direction. Rather than canceling one another out, the microscopic magnetic fields combine to create one large magnetic field. The more domains point in the same direction, the stronger the overall field. Each domain's magnetic field extends from its north pole into the south pole of the domain ahead of it.
This explains why breaking a magnet in half creates two smaller magnets with north and south poles. It also explains why opposite poles attract -- the field lines leave the north pole of one magnet and naturally enter the south pole of another, essentially creating one larger magnet. Like poles repel each other because their lines of force are traveling in opposite directions, clashing with each other rather than moving together.