In magnetism, we can visually demonstrate that the number of magnetic field lines leaving the surface is balanced by the number of lines entering it. The net magnetic flux is zero for both the surfaces. This is true for any closed surface.
Consider a small vector area element ΔS of a closed surface S as in Fig. The magnetic flux through ΔS is defined as ΔϕB = B.ΔS, where B is the field at ΔS. We divide S into many small area elements and calculate the individual flux through each. Then, the net flux ϕB is,
Comparing this with the Gauss law for electrostatics, in that case is given by
where q is the electric charge enclosed by the surface.
The difference between the Gauss electrostatics is a reflection of the fact that isolated magnetic poles (also called monopoles) are not known to exist. There are no sources or sinks of B; the simplest magnetic element is a dipole or a current loop. All magnetic phenomena can be explained in terms of an arrangement of dipoles and/or current loops.
Thus, Gauss law in magnetism states that the net magnetic flux through any closed surface is zero.