An electromagnet is, essentially, a wire coiled around a core; this core can be anything, even air. The electromagnet's strength is related to what the core is made of (metallic cores will produce a stronger magnet), how many times the wire is coiled around the core, and how much of the core is covered with coils. To produce a magnetic field, the wire must be attached to a power source, such as a battery. As electricity runs through the wire, through the coils, and back to the battery, a magnetic field is produced. The voltage of the electricity running through the wire also affects the strength of the magnet. If the wire is disconnected from the power source, the magnetic field will vanish.