Electromagnet
Magnetic core

This phenomenon occurs because the magnetic core's material (often iron or steel) is composed of small regions called magnetic domains that act like tiny magnets (see ferromagnetism). Before the current in the electromagnet is turned on, these domains point in random directions, so their tiny magnetic fields cancel each other out, and the core has no large-scale magnetic field. When a current passes through the wire wrapped around the core, its magnetic field penetrates the core and turns the domains to align in parallel with the field. As they align, all their tiny magnetic fields add to the wire's field, which creates a large magnetic field that extends into the space around the magnet. The core concentrates the field, and the magnetic field passes through the core in lower reluctance than it would when passing through air.
punctuation:no_comma