Unit content
Gauss's law for electricity
Electric charge is a source of electric field. Gauss's law expresses this by relating the electric flux through any closed surface to the net charge enclosed by that surface:
$$\oint_S\mathbf E\cdot d\mathbf A=\frac{Q_{\mathrm{enc}}}{\varepsilon_0}.$$
Enclosed charge
Only charge inside the chosen closed surface contributes to $Q_{\mathrm{enc}}$. Charges outside can affect the field at the surface, but their total contribution to the net flux through the closed surface cancels.
Gaussian surfaces
The closed surface used in the law is an imaginary mathematical surface, not a physical boundary. Any shape is valid.
The law becomes especially useful for calculating fields when symmetry makes $\mathbf E\cdot d\mathbf A$ simple over the surface, such as spherical, cylindrical or planar symmetry.
Example of spherical symmetry
For a point charge $Q$, choose a sphere of radius $r$. The field has constant magnitude on the sphere and points normally outward, so
$$E(4\pi r^2)=\frac{Q}{\varepsilon_0},$$
which gives the familiar inverse-square electric field.
Gauss's law is always true; symmetry determines whether it is a convenient way to solve for the field.