Electromagnetism is the name we give to explain magic. Okay, so maybe not magic but it is dammed close! Using electromagnets we can literally make trains float above the track like in the MagLev train. Don't believe me? That's fine, I didn't when I was first told about this - but here's a video to prove it.
So - how on earth does this work? It's a set of complicated principles that allow electricity to make a magnetic field - and it's a principle that we make use of every day. 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) are 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 increasing the strength of the field around the wire.
This is what the field looks like when we make a solenoid:
By Goodphy - Own work, CC BY-SA 4.0, https://commons.wikimedia.org/w/index.php?curid=74899571
As you can see - this magnetic field now looks a lot like what you would find around a magnet - we're on our way to making something that will be able to lift a whole train into the air.
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 loses it 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.