The magnetic flux through a surface—when the magnetic field is variable—relies on splitting the surface into small surface elements, over which the magnetic field can be considered to be locally constant. The total flux is then a formal summation of these surface elements (see surface integration
Each point on a surface is associated with a direction, called the surface normal
; the magnetic flux through a point is then the component of the magnetic field along this direction.
The magnetic interaction is described in terms of a vector field, where each point in space (and time) is associated with a vector that determines what force a moving charge would experience at that point (see Lorentz force).  Since a vector field is quite difficult to visualize at first, in elementary physics one may instead visualize this field with field lines. The magnetic flux through some surface, in this simplified picture, is proportional to the number of field lines passing through that surface (in some contexts, the flux may be defined to be precisely the number of field lines passing through that surface; although technically misleading, this distinction is not important). Note that the magnetic flux is the net number of field lines passing through that surface; that is, the number passing through in one direction minus the number passing through in the other direction (see below for deciding in which direction the field lines carry a positive sign and in which they carry a negative sign). In more advanced physics, the field line analogy is dropped and the magnetic flux is properly defined as the surface integral of the normal component of the magnetic field passing through a surface. If the magnetic field is constant, the magnetic flux passing through a surface of vector area S is
where B is the magnitude of the magnetic field (the magnetic flux density) having the unit of Wb/m2 (tesla), S is the area of the surface, and θ is the angle between the magnetic field lines and the normal (perpendicular) to S. For a varying magnetic field, we first consider the magnetic flux through an infinitesimal area element dS, where we may consider the field to be constant:
A generic surface, S, can then be broken into infinitesimal elements and the total magnetic flux through the surface is then the surface integral
From the definition of the magnetic vector potential A and the fundamental theorem of the curl the magnetic flux may also be defined as:
where the line integral is taken over the boundary of the surface S, which is denoted ∂S.