Electromagnetism is the name we give to explain magic. Okay, so maybe not magic but it is very close! Using electromagnets we can literally make trains float above the track like in the MagLev train. Sounds hard to believe, doesn't it!
So, how on earth does this work? It's a set of complicated principles that allow electricity to make a magnetic field. What's more, we make use of this principle in everyday life! Maybe not in such a big and dramatic way as the MagLev train, but it's inside nearly all of our electronic equipment.
The thing is that electric currents (moving electrons) have magnetic fields around them. A straight wire carrying electricity has a circular magnetic field around it, whereas, a coil of wire has a magnetic field in the same shape as a magnet. Just like with all fields, you can't see this, but you can see the effects of this. Here is a video showing you how a wire will be affected when a current (moving electrons) is passed through it.
Using that principle, it is easy to make a simple electromagnet, we just take the wire and make it into a coil. This is called a solenoid and has the effect of increasing the strength of the field around the wire.
We can then improve this even further but putting an iron core into the coiled wire to improve the field even more.
The magnetic field around an electromagnet can be increased by increasing the current in the wire, making more loops with wire and placing an iron or steel core inside the wire, as shown in the diagram above.
Iron is magnetically soft, so it is easy to magnetise and it loses its magnetism when the electric current is turned off. Steel is magnetically hard, which makes it hard to magnetise, but it stays magnetic after the current is switched off.