The net electric flux through any closed surface is proportional to the charge enclosed by the surface (in this case a sphere or a cube). Notice that when the charge is inside the surface, all vectors representing the electric flux point outward, but when the surface is moved and no longer encloses the charge, the flux entering one side exits the opposite side and the net flux equals zero.

This law was formulated by Carl Friedrich Gauss in 1835 and it is the basis for the first of Maxwell's equations.

The law can be expressed in differential form as , where is the divergence of the electric field, is the charge density, and is the permittivity of free space. This can be rewritten in integral form as , where is the differential element of area in the integration over the closed surface and is the enclosed charge.