Rule 1 - Lowest energy orbitals fill first. Thus, the filling pattern is 1s, 2s, 2p, 3s, 3p, 4s, 3d, etc. Since the orbitals within a subshell are degenerate (of equal energy), the entire subshell of a particular orbital type is filled before moving to the next subshell of higher energy.
Rule 2 - Pauli Exclusion Principle - Only two electrons are permitted per orbital and they must be of opposite spin. If one electron within an orbital possesses a clockwise spin, then the second electron within that orbital will possess a counterclockwise spin. Two electrons with opposite spins found in the same orbital are referred to as being paired.
Rule 3- Hund's Rule - The most stable arrangement of electrons in a subshell occurs when the maximum number of unpaired electrons exist, all possessing the same spin direction. This occurs due to the degeneracy of the orbitals, all orbitals within a subshell are of equal energy. Electrons are repulsive to one another and only pair after all of the orbitals have been singly filled.