B-field lines never endMain article: Gauss's law for magnetism
Field lines are a useful way to represent any vector field and often reveal sophisticated properties of fields quite simply. One important property of the B-field revealed this way is that magnetic B field lines neither start nor end (mathematically, B is a solenoidal vector field); a field line either extends to infinity or wraps around to form a closed curve.[nb 8] To date no exception to this rule has been found. (See magnetic monopole below.)
Magnetic field lines exit a magnet near its north pole and enter near its south pole, but inside the magnet B-field lines continue through the magnet from the south pole back to the north.[nb 9] If a B-field line enters a magnet somewhere it has to leave somewhere else; it is not allowed to have an end point. Magnetic poles, therefore, always come in N and S pairs. Cutting a magnet in half results in two separate magnets each with both a north and a south pole.
More formally, since all the magnetic field lines that enter any given region must also leave that region, subtracting the 'number'[nb 10] of field lines that enter the region from the number that exit gives identically zero. Mathematically this is equivalent to:
where the integral is a surface integral over the closed surface S (a closed surface is one that completely surrounds a region with no holes to let any field lines escape). Since dA points outward, the dot product in the integral is positive for B-field pointing out and negative for B-field pointing in.
There is also a corresponding differential form of this equation covered in Maxwell's equations below.
H-field lines begin and end near magnetic poles
Unlike B-field lines, which never end, the H-field lines due to a magnetic material begin in a region(s) of the magnet called the north pole pass through the magnet and/or outside of the magnet and ends in a different region of the material called the south pole. Near the north pole, therefore, all H-field lines point away from the north pole (whether inside the magnet or out) while near the south pole (whether inside the magnet or out) all H-field lines point toward the south pole. (The B-field lines, for comparison, form a closed loop going from south to north inside the magnet and from north to south outside the magnet)
The H-field, therefore, is analogous to the electric field E which starts at a positive charge and ends at a negative charge. It is tempting, therefore, to model magnets in terms of magnetic charges localized near the poles. Unfortunately, this model is incorrect; for instance, it often fails when determining the magnetic field inside of magnets. (See "Non-uniform magnetic field causes like poles to repel and opposites to attract" below.)
Outside a material, though, the H-field is identical to the B-field (to a multiplicative constant) so that in many cases the distinction can be ignored. This is particularly true for magnetic fields, such as those due to electric currents, that are not generated by magnetic materials.