An atom is surrounded by a cloud of
electrons. This cloud is organised into separate probability distributions each of which can contain up to two electrons. These probability distributions are referred to as electron
orbitals (harping back to the time before particle/wave duality and quantum physics when the electrons were thought to orbit the
nucleus like the
moon around the
earth).
The orbitals are grouped into sets by their symmetry there are 4 known sets of orbitals which are called s, p, d, and f. The number of orbitals increases for each type so that while there is only 1 s orbital per shell there are 7 f orbitals. Each orbital holds 2 electrons.
The letters come from name given to the appearance of the lines from the orbitals in spectra.
There are shells of orbitals that increase in energy at the higher shells. Shell 1 only contains an s orbital and each shell adds the next orbital type so shell 2 has s and p orbitals etc. The energies of the shells overlap so that for instance the 4s shell has a lower energy than the 3d shell. The actual filling is shown below.
1s 2 electrons 2 total
2s 2p 8 electrons 10 total
3s 3p 8 electrons 18 total
4s 3d 4p 18 electrons 36 total
5s 4d 5p 18 electrons 54 total
6s 4f 5d 6p 32 electrons 86 total
7s 5f 6d 7p 32 electrons 118 total
This filling order while generally correct does have slight irregularities due to the closeness (energetically) of certain orbital groups during partial filling.
It is the reactivity and properties of the outer electrons that determine the general chemistry of an element. Thus the ordering of the shells and orbitals explains the order of the elements and the size of the various rows in the periodic table.