A magnetic field is a vector field which surrounds magnets and electric currents, and is detected by the force it exerts on moving electric charges and on magnetic materials. When placed in a magnetic field, magnetic dipoles tend to align their axes parallel to the magnetic field. Magnetic fields also have their own energy with an energy density proportional to the square of the field intensity.
For the physics of magnetic materials, see magnetism and magnet, and more specifically ferromagnetism, paramagnetism, and diamagnetism. For constant magnetic fields, such as are generated by magnetic materials and steady currents, see magnetostatics. A changing electric field results in a magnetic field, and a changing magnetic field also generates a electric field (see electromagnetism).
In special relativity, the electric field and magnetic field are two interrelated aspects of a single object, called the electromagnetic field. A pure electric field in one reference frame is observed as a combination of both an electric field and a magnetic field in a moving reference frame.