The Divergence Theorem
Link the outside and the inside
The gold cube is the closed surface, and the cyan lines are a grid cutting its inside into small cells. Increasing the divisions with the buttons adds more shared faces between cells, and on such a face whatever one side sends out the other side takes in, so they cancel like the pair of gray arrows. What survives to the end is only the gold arrows leaving through the outer faces.
A bridge between surface and interior
Gauss's law speaks of the flux measured on a closed surface, the outside. The divergence theorem links this outside flux to the divergence at every point inside, added up over the whole volume. ∮E·dA = ∫(∇·E)dV. This bridge, which says that what is measured on the surface equals what is measured inside the volume, is not a physical law for the electric field alone but a mathematical theorem that holds for any smooth vector field.
Why it holds — neighbors cancel
Split the region into small cells, find the net flux of each cell, and add them all. On an inner face shared by two cells, the flow one cell sends out is exactly the flow entering its neighbor, so the two values have opposite signs. The inner faces therefore cancel in pairs, and the only faces left without a partner are those on the outer boundary. In the end, adding the flux of every cell leaves only the flux through the outer boundary.
Divergence, the source per unit volume
Shrink a cell without limit, and its net flux divided by its volume becomes the divergence ∇·E at a point, the amount of field springing out of that point per unit volume. A point with positive divergence holds a source that sends out field (positive charge), and a point with negative divergence holds a sink that draws field in (negative charge). The divergence theorem says that gathering these point-by-point outflows over the whole volume gives the outside flux.
The differential form of Gauss
Put the divergence theorem into Gauss's law. The outside flux ∮E·dA is Q/ε₀, and the inside is ∫(∇·E)dV. The enclosed charge Q is the charge density integrated over the volume, ∫ρ dV. Then ∫(∇·E)dV = ∫(ρ/ε₀)dV holds for any volume you choose, so the two integrands must be equal. ∇·E = ρ/ε₀. The one-line integral form has turned into a differential form that holds at every point, and this is the first of Maxwell's equations.
Back to the first screen
On the first screen, the finer you split the region, the more shared faces crowded the inside, but they all canceled in pairs. Only the faces of the outer boundary survived to the end. That is why the volume integral that adds up the divergence of every cell exactly equals the outer surface integral. ∮E·dA = ∫(∇·E)dV. Set this bridge on top of Gauss's law and the differential form ∇·E = ρ/ε₀ comes out.
The divergence theorem is a tool for moving freely between surface integrals and volume integrals. With it equipped, you get the differential form of Gauss's law, ∇·E = ρ/ε₀ (Maxwell 1·EM-22), and it pairs with its companion theorem around closed loops, Stokes' theorem (EM-16). The integral form serves problems with symmetry, and the differential form serves the local structure of fields and Maxwell's equations.