The electrons in an atom fill up its atomic orbitals according to the Aufbau Principle; "Aufbau," in German, means "building up." The Aufbau Principle, which incorporates the Pauli Exclusion Principle and Hund's Rule prescribes a few simple rules to determine the order in which electrons fill atomic orbitals:
The outermost orbital shell of an atom is called its valence shell, and the electrons in the valence shell are valence electrons. Valence electrons are the highest energy electrons in an atom and are therefore the most reactive. While inner electrons (those not in the valence shell) typically don't participate in chemical bonding and reactions, valence electrons can be gained, lost, or shared to form chemical bonds. For this reason, elements with the same number of valence electrons tend to have similar chemical properties, since they tend to gain, lose, or share valence electrons in the same way. The Periodic Table was designed with this feature in mind. Each element has a number of valence electrons equal to its group number on the Periodic Table. This table illustrates a number of interesting, and complicating, features of electron configuration.
First, as electrons become higher in energy, a shift takes place. Up until now, we have said that as the principle quantum number, increases, so does the energy level of the orbital. And, as we stated above in the Aufbau principle, electrons fill lower energy orbitals before filling higher energy orbitals. However, the diagram above clearly shows that the 4s orbital is filled before the 3d orbital. In other words, once we get to principle quantum number 3, the highest subshells of the lower quantum numbers eclipse in energy the lowest subshells of higher quantum numbers: 3d is of higher energy than 4s.
Second, the above indicates a method of describing an element according to its electron configuration. As you move from left to right across the periodic table, the above diagram shows the order in which orbitals are filled. If we were the actually break down the above diagram into groups rather than the blocks we have, it would show how exactly how many electrons each element has. For example, the element of hydrogen, located in the uppermost left-hand corner of the periodic table, is described as 1s1, with the s describing which orbital contains electrons and the 1 describing how many electrons reside in that orbital. Lithium, which resides on the periodic table just below hydrogen, would be described as 1s22s1. The electron configurations of the first ten elements are shown below (note that the valence electrons are the electron in highest energy shell, not just the electrons in the highest energy subshell).
Our discussion of valence electron configurations leads us to one of the cardinal tenets of chemical bonding, the octet rule. The octet rule states that atoms become especially stable when their valence shells gain a full complement of valence electrons. For example, in above, Helium (He) and Neon (Ne) have outer valence shells that are completely filled, so neither has a tendency to gain or lose electrons. Therefore, Helium and Neon, two of the so-called Noble gases, exist in free atomic form and do not usually form chemical bonds with other atoms.
Most elements, however, do not have a full outer shell and are too unstable to exist as free atoms. Instead they seek to fill their outer electron shells by forming chemical bonds with other atoms and thereby attain Noble Gas configuration. An element will tend to take the shortest path to achieving Noble Gas configuration, whether that means gaining or losing one electron. For example, sodium (Na), which has a single electron in its outer 3s orbital, can lose that electron to attain the electron configuration of neon. Chlorine, with seven valence electrons, can gain one electron to attain the configuration of argon. When two different elements have the same electron configuration, they are called isoelectronic.
The electron configuration of an atom also has consequences on its behavior in relation to magnetic fields. Such behavior is dependent on the number of electrons an atom has that are spin paired. Remember that Hund's Rule and the Pauli Exclusion Principle combine to dictate that an atom's orbitals will all half-fill before beginning to completely fill, and that when they completely fill with two electrons, those two electrons will have opposite spins.
An atom with all of its orbitals filled, and therefore all of its electrons paired with an electron of opposite spin, will be very little affected by magnetic fields. Such atoms are called diagmetic. Conversely, paramagnetic atoms do not have all of their electrons spin-paired and are affected by magnetic fields. There are degrees of paramagnetism, since an atom might have one unpaired electron, or it might have four.