Afbau principle states that the electrons are filled in the orbital according to their energy level. Lower energy shells are first filled and then higher energy shell are filled.
The order of filling of orbitals are s-p-d-f.
So, elements with last electron in respective orbitals show similar properties. And this serves as the basis of format of periodic table.